How do I get the 2.5d platformer's rigidbody physics to follow a path?


I'm using itween's PutOnPath function to place the character on a path but I'm not sure how I can get collision detection working for the character and restrict physics to a path. Is that possible?

Example of problem: (boxes have rigidbodies attached, but only travel on the X axis)

Should I just raycast from the character to detect collisions instead? I am not sure what's an adequate approach to this problem.

I'd recommend the raycast route on this one. I really like the way this works - it's inspiring to see your work evolve and I appreciate you sharing this. If you can't figure out a suitable solution to this let me know and maybe I'll take another look.

Hello there

Did you find a solution for this? It looks like I'm making just the same type of game you are, and stumbled upon this question.

I have also thought about finding out the closest point on the spline for the point that the rigidbody is at, and then setting its pointOnPath to that amount. Then on every FixedUpdate set the body's position to that PointOnPath. I might have the ClosestPointOnPath method done by this evening.

I also considered overriding OnCollisionEnter. But with only the contacts list and the relativeVelocity information, it would be too difficult for me to implement a collision constraint to the path.

So, any progress? Anything you can share?