Moving along a boundary
I have an actor that moves towards wherever the player touches on the screen (once 'mouse button is up') with veloctiy game.speed and angle game.angle defined by his relative position to the touch. However, I want to have boundaries I can place on the scene that the actor cannot pass through. And when the actor collides with a boundary, he moves along it's borders if the touch is past the boundary. Any ideas on how I could achieve this? Is there a function I can use to determine the angle of the boundary he collides with and somehow alter game.angle to make him move along it?
Any tips are appreciated!
Any tips are appreciated!
Best Answer
-
master200012 Posts: 372
Well, you should probably just have the actor constrain it's own rotation to the direction it's moving instead. (VectorToAngle its linear velocities)
Then create boundaries by moving transparent actors of different sizes around.
Instead of constraining the actor's speed to game.speed, have it change velocity to that speed towards game.angle.
If you don't want the actor to bounce of the walls, set both restitutions to 0 and uncheck the movable box in the boundaries.
Actually, I'm not sure what you wanted exactly, but I hope this helps! Good Luck! :P
Answers