1 decade ago by alexandre
I'm experiencing unwanted motion drift for an entity moving in the direction that it is facing at degree rotation values other than multiples of 45. Here is update, and the results at -15 degrees:
heading: -15, update: function() { var headingRad = (this.heading).toRad(); this.currentAnim.angle = headingRad; var thrust = 10; this.accel.x = thrust * Math.cos(headingRad); this.accel.y = thrust * Math.sin(headingRad); this.wrapAroundIf(); // bring back in screen bounds? this.parent(); }
1 decade ago by dominic
Did your entity reach .maxVel on one of the axis? (Man, having the default at
100
was a really bad decision...) 1 decade ago by quidmonkey
Apply the angle to your vel vs. your accel. maxVel will throw it off, but since accel is incremental, you're incrementally changing your angle by constantly adding/subtracting to it. At least, I think....
Also check your friction, if your x & y doesn't match, that'll throw it off.
Also check your friction, if your x & y doesn't match, that'll throw it off.
1 decade ago by alexandre
It was maxVel. As soon as reached, drifting began of course. Quid, I want the ship to accelerate along its heading vector, hence chose to apply force to accel and not vel. Thanks guys. Much appreciated.
Page 1 of 1
« first
« previous
next ›
last »