Hi,
I’m new to the engine and I’m exploring a little bit the math API. I want to do a simple quaternion lerp but unfortunately I get something wrong when playing, it’s not lerping but rather directly going to the “To” quat. Also I think it’s really strange to call the lerp directly on the transform’s rot because of the redundancy of the from argument. A static function in the Quat class would have been great but I couldn’t find it, maybe I’ve missed something ? I know that Quat.lerp is inlined so it’s more efficient but why not having an override that only takes a “to” quat and the t ?
Here is my code:
class PlayerController extends iron.Trait {
var toRot:Quat;
var start:Bool;
public function new() {
super();
notifyOnInit(function() {
var initEuler = object.transform.rot.getEuler();
toRot = object.transform.rot.fromEuler(initEuler.x, -100.0, initEuler.z);
});
notifyOnUpdate(function() {
if(Input.getKeyboard().down("space"))
{
start = true;
}
if(start)
{
object.transform.rot = object.transform.rot.lerp(object.transform.rot, toRot, Time.delta * 0.1);
object.transform.buildMatrix();
}
});
// notifyOnRemove(function() {
// });
}
}
Thanks !