p2.js
p2.js copied to clipboard
Question: How to achieve entities on predefined paths?
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)]