Download

How to move a physics object along a path/guide?

Hey all, I’m trying to figure out how I can make a physics object (ball) follow a path/guide but not linearly. Essentially, the path would act as a guide that enables the ball to move along it but any physics elements that affect the ball would alter the movement of the ball. So for instance. If the path is a straight line from point “a” to point “b”, the ball would follow the path in a straight line. However, if I applied a force to the ball in the x direction, the ball would still move forward along the path but also now be moving in the x direction by the force being applied. Of course this is a simple example. I’m thinking about moving a ball in a spiral pattern. This leads me to believe that this may be achieved using a spline? I’m just not sure how to go about allowing my ball to move freely from the spline and not just be “stuck” to it? Any help could be great, thanks!

You could try getting the closest world location on the spline (there’s a node) and attract the ball to that point with small force that can be overcome with another, stronger - user generated force.


If the ball is supposed to also follow the spline path on its own, you could generate a vector along the path that keeps following it. The closer the simulated object is to that location, the further we push it along the path. That point attracts the ball with varying force, like a spring or a magnet.

The engine actually has vector springs so perhaps you could use that. Ensure you have some clamps in place or you’ll make a railgun.