So a few things I’m not sure about with the ‘this.entity.rotate’ function.
It seems static based on this code I did, and what I mean by static is that it’s rotating my object but not updating the ‘this.entity.foward’ instead just reseting to the original forward direction the scene starts in.
var ForwardAndRotation = pc.createScript('forwardAndRotation');
ForwardAndRotation.prototype.initialize = function() {
this.moveSpeed = 5;
};
ForwardAndRotation.prototype.update = function(dt) {
var forward = this.entity.forward;
if(this.app.keyboard.isPressed(pc.KEY_W)){
this.entity.rigidbody.applyForce(forward.scale(this.moveSpeed));
}
this.entity.rotate(0,1,0);
};
If I were to rotate the object in the editor it would update in the object’s forward direction no problem. It’s only when I use the ‘this.entity.rotate’ function where it doesn’t care at all. Same with setting the rotation or euler angles. The only thing I found that works for turning the object in scene is ‘applyTorque’ but I just don’t understand why this is happening.
Another weird thing is that the rotation code I wrote takes like 1 second to actually begin rotating which is also weird.
Just curious if you guys had information on all these issues since I’d like to understand what is going on. Again using Torque seems to be the right solution to rotate the object the way I want (with updating it’s foward vector) but it just seems more intuitive to use the rotate functions so yea some light on this would be helpful.
Here is a link to my project >> https://playcanvas.com/project/586549/overview/questions