Transform it works armrory 3D


#1
    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");

}

}


#2

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


#3

Perhaps

object.transform.loc.x  +=   1;

object.transform.loc.x  -=   1;


#4

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.