schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

Question: How to achieve entities on predefined paths? #346

Open AndrewRayCode opened 5 years ago

AndrewRayCode commented 5 years ago

I have a system in my game where I can define a simple path for an entity to take, like moving through a circle in a loop. This entity's physics positions are updated every frame to snap to the right path position. An issue is if my player gets trapped between the object on the path and a wall, the object will just continue to move and eventually fully squish the player.

Is there a solution to this, where I could make the object move along a path but not be able to continue through solid objects?

If it's relevant, I'm basically forcing the path position right now, as in

position = [sin(time), cos(time)]