I’m trying to grab the current position and previous position of the player character so I can get it to rotate to face the direction it’s moving, but I’ve noticed something strange happening with entity.getLocalPosition().
PlayerController.prototype.update = function(dt) {
var currentPosition = this.entity.getLocalPosition();
console.log("current position = " + currentPosition);
}
When the player character is moving, getLocalPosition() returns a Vec3 the way I’d expect it to that looks like the correct position; as soon as it stops moving, getLocalPosition returns [0, 0, 0] consistently until it starts moving it again.
The entity isn’t a child of anything except the Root, so I’m not sure why this is happening. Can anyone shed light on this? I’m moving the player in a different script using forces, if that makes a difference.