CalmNearEnd Posted November 27, 2014 Share Posted November 27, 2014 Hi, I'm using game.physics.arcade.moveToPointer to make a bullet fly where I click: game.physics.arcade.moveToPointer(bullet, bulletSpeed); But I want my character to recoil and fly backwards when he shoots.I'm trying it like so: angleToPointer = game.physics.arcade.angleBetween(player, game.input); game.physics.arcade.velocityFromAngle(angleToPointer -180, 300, player.body.velocity); But it's not working. Any help? Thanks Link to comment Share on other sites More sharing options...
lewster32 Posted November 28, 2014 Share Posted November 28, 2014 The main issue is that angleBetween returns the angle in radians (I guess this method should really be called rotationBetween for consistency) but velocityFromAngle expects the value in degrees. Here's a working example: http://jsfiddle.net/lewster32/5vkru16m/ jpdev 1 Link to comment Share on other sites More sharing options...
CalmNearEnd Posted November 30, 2014 Author Share Posted November 30, 2014 Thank you! That fixed it. Link to comment Share on other sites More sharing options...
Recommended Posts