Transform it works armrory 3D

    package arm;

import armory.trait.internal.CanvasScript;
import armory.system.Event;
class Player extends iron.Trait {
var addX:Int;
var canvas:CanvasScript;
public function new() {
super();

	notifyOnInit(function() {
		canvas = iron.Scene.active.getTrait(CanvasScript);

		// Notify on button click
		Event.add("up", up);
		Event.add("down", down);
	});

	// notifyOnUpdate(function() {
	// });

	// notifyOnRemove(function() {
	// });
}
function up(){
	addX+=1;
	object.transform.loc.x=1;
	trace("up");

}
function down(){
	addX-=1;
	object.transform.loc.x=-1;
	trace("down");

}

}

I can not move the cube, how to solve this?

Perhaps

object.transform.loc.x  +=   1;

object.transform.loc.x  -=   1;

You have to call object.transform.buildMatrix() after any modification of the loc, rot, or scale of object.transform. This will apply the changes you’ve made to those variables and update the transform.

1 Like