So I have a script to move a cube. The script is called and trace() tells me that the cube is transformed along the x axis. It doesn’t do anything. The same script moves the camera successfully. I give the cube an animation to see if this is some render fluke. It flickers, half the time completing the animation, and the other half listening to the script. Best I can figure, adding a keyframe flips some sort of switch in Armory that makes this “animatable”. Is there some sort of way I can make this work without a hideous flicker? Thanks to those who respond.
P.S. If you want to see the blend and/or script, I can provide it, but the script will almost certainly fail, unless you have a clone of my computer running a server on your network. Hence the usefulness is slightly diminished.
What is the code you use to move a cube? Does object.transform.translate() work? If you modify the vectors directly, try calling object.transform.buildMatrix() afterwards. Quick example here.
object.transform.translate() doesn’t work for me, regardless of whether I add buildMatrix()… .set() is much the same. the code is as follows, with the unimportant areas cut out.
function updateObject(root:Object,desired:Dynamic):Bool {
for (o in root.children) {
if (o.name==desired.Name) {
//update
// o.transform.loc.x=desired.Loc.X;
// o.transform.loc.y=desired.Loc.Y;
// o.transform.loc.z=desired.Loc.Z;
// o.transform.update();
o.transform.loc.set(desired.Loc.X,desired.Loc.Y,desired.Loc.Z);
o.transform.buildMatrix();
// o.transform.update();
trace(o.transform.loc,o.name);
// o.transform.rot=o.transform.rot.fromEuler(Math.acos(desired.Loc.X),Math.acos(desired.Loc.Y),Math.acos(desired.Loc.Z));
trace("unto the breach!");
o.properties=new Map<String,Int>();
o.properties.set("TrajectX",desired.Trajectory.X);
o.properties.set("TrajectY",desired.Trajectory.Y);
o.properties.set("TrajectZ",desired.Trajectory.Z);
// o.transform.loc.x=Math.acos(desired.Rot.X);
return true;
}
if (updateObject(o,desired)) {
return true;
}
}
return false;
}
(“desired” is a json object)
And for translate():
function clientsidepredict(root:Object) {
for (ob in root.children) {
trace(ob.name);
if (null!=ob.properties&&ob.properties.exists("TrajectX")) {
trace("Aha");
var divBy=FPS/serverFPS;
ob.transform.translate(ob.properties.get("TrajectX")/divBy,ob.properties.get("TrajectY")/divBy,ob.properties.get("TrajectZ")/divBy);
// ob.transform.loc.x+=ob.properties.get("TrajectX")/divBy;
// trace(divBy);
// ob.transform.loc.y+=ob.properties.get("TrajectY")/divBy;
// ob.transform.loc.z+=ob.properties.get("TrajectZ")/divBy;
ob.transform.buildMatrix();
}
clientsidepredict(ob);
}
}
Perhaps the issue is that haxe has decided to a pain in the rear again and doesn’t pass pointers by default - If it made copies of objects it would explain a little bit. However, I seem to remember reading it wasn’t the case… Could be something to experiment with.
Pardon the commented lines, I like to leave them for reference.
And besides it showed “functionality” when I put an animation on it. Maybe blender can do local space animations, if so I could just cheat with an animation at zero.
–Edit–
Even with a delta keyframe, it flickers and occasionally seems invisible. In addition, it seems to cover the camera at times. At least it moves, but it by no means looks pretty.
Oh. I left passive rigid body on… I mean, it shouldn’t actually matter, but it feels slightly embarrassing I didn’t notice. Ah well. It works now, thanks for your patience.