NistorCristian Posted January 27, 2016 Share Posted January 27, 2016 Hello, I'm trying to implement a missile based on this example: http://gamemechanicexplorer.com/#homingmissiles-1 If I change the physics from arcade to box2d the missile doesn't follow the pointer. I tried to see what the problem is and I think is this.rotation. Box2d sees rotation different from arcade. How can I fix this ? if (this.rotation !== targetAngle) { // Calculate difference between the current angle and targetAngle var delta = targetAngle - this.rotation; // Keep it in range from -180 to 180 to make the most efficient turns. if (delta > Math.PI) delta -= Math.PI * 2; if (delta < -Math.PI) delta += Math.PI * 2; if (delta > 0) { // Turn clockwise this.angle += this.TURN_RATE; } else { // Turn counter-clockwise this.angle -= this.TURN_RATE; } // Just set angle to target angle if they are close if (Math.abs(delta) < this.game.math.degToRad(this.TURN_RATE)) { this.rotation = targetAngle; } } Thank you Link to comment Share on other sites More sharing options...
Recommended Posts