How to get an actor to accelerate towards another actor and still be able to move
In my game, the player is supposed to be pulled towards another actor, like a black hole. I stored the black hole's position in two game variables and told my actor to accelerate to that position. However, I have one problem. In game, when I move the player in any direction using the arrow keys (There is no gravity), even just 1 pixel, the acceleration suddenly stops and does not start again until I let go of the key. Once I let go of the key, the acceleration starts again from a speed of 0. I want my movement speed to be added on to my acceleration speed so the player can fight against the acceleration or move with it and go faster.
Best Answer
-
jamie_c ImagineLabs.rocks Posts: 5,772
I'm guessing you are using Move Behaviors to move your player, you'll need to use Accelerate instead. I've hacked together a quick demo for you to check out. This isn't perfect, just thrown together to give you the direction. Use the arrow keys to stay away from the black hole.