BatBut Posted January 3, 2018 Share Posted January 3, 2018 Hey everyone, I am having an issue with accelerationFromRotation sending my player in the wrong direction. I'm setting it up so that the player will be spinning using angularVelocity and when you press space it moves in the direction that it's currently facing. To do that I'm using accelerationFromRotation to get a point then using moveToXY to push them in that direction. This definitely works some of the time, but most of the time it send the player in a seemingly random direction, so I think I'm missing something about how this is meant to work. Could someone enlighten me? Edit: I should add that I know moveToXY will try to move the whole way to the end of the point object which is beyond the screen, so I'm using drag to slow it down so that it is just a shove rather than a fling to the distance This is the function I'm using to move the player: function shunt() { playerRotate = false;//so we know the player isn't spinning while they move player.body.angularVelocity = 0; //actually stopping the spinning var goTo = game.physics.arcade.accelerationFromRotation(player.previousRotation, 300, player.body.acceleration);//to make the point to move towards game.time.events.add(Phaser.Timer.SECOND / 2, slooooow, this); //wait half a second then start rotation again game.physics.arcade.moveToXY(player, goTo.x, goTo.y, 600); //move the player towards the point function slooooow() { playerRotate = true; } } Link to comment Share on other sites More sharing options...
samme Posted January 4, 2018 Share Posted January 4, 2018 accelerationFromRotation assigns and returns a vector (acceleration), not a position. In this snippet, goTo is identical to player.body.acceleration. moveToXY assigns to player.body.velocity. So you don't want to use both. Link to comment Share on other sites More sharing options...
Recommended Posts