Model Following a Path

Does anyone have an example or could point me in the right direction.

I want to create a race track with 5 slots(path) and have cars(model) running around the track following the slots. Im not sure where to start with this any ideas.

1 Like

There are a few of ways you could do this.

  • You could export an animation from your 3D tool (Blender, 3DS Max) and attach car models to the animated bone in code. As you play the animation, the car model will follow the path. We often do this with camera tracks.

  • You could use the Curve script attribute to add x,y,z curves. And use these to define your path. This might be a bit clumsy.

  • You could write your own Spline code and define Splines which outline the tracks. The cars can follow these.

1 Like

Hi Dave, regarding your first solution to the issue, what is the proposed way to attach an entity to a bone?

Each bone is actually a Node in hierarchy of a model, and you can find it same way as you find other Nodes (entities) using findByName for example. So if you have animated path, and then you’ve named Node that is animated along the path as pivot (example), then do this: animatedModel.findByName("pivot").addChild(model);. This will find pivot within animatedModel and then add model as it’s child.

Try experimenting with it.