Advertisement

Unity: How to make such tracks and have something follow it

Started by April 06, 2022 10:53 PM
6 comments, last by Ultraporing 2 years, 7 months ago

I am new to unity and trying to learn new things. I came accross this game but stuck at thinking about how to make suck curvy track in unity (its not in terrain I guess). And how to make object follow it and automatically turn over curves.

Is track done in blender and imported? Then how do object follow it even at curves.

This WAS a great video on the issue but after watching a few seconds and reading the comments, I realize that the video has been edited (to remove the game footage at the start I think) and now the audio timing is way off, making it very hard to watch. Sorry.

I do have the original downloaded. If you find this video interesting, I will upload the “watchable” version for you.

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

Advertisement

@undefined thank you Fleabay, I am going through the video and will try to figure out the solution.

You would have to use a pathfinding system.

Very simple way is to use a waypoint method. Simply have an empty game object tagged “Waypoint”. Then just make an empty child for that object and another child and another child.. etc..
The object to go down the path will find the “Waypoint” object and move to it, once it reaches it, it will move to the child.. then to the next child… etc..

Game Dev since 2004

The video that fleabay posted is great.

Here is a ready made free solution I found on the asset store, maybe it helps as a reference for your learning: https://assetstore.unity.com/packages/tools/modeling/splinemesh-104989

Here is a full tutorial on how to create the spline editor script to visually create them in the editor and have something following it​: https://catlikecoding.com/unity/tutorials/curves-and-splines/

Cheers

“It's a cruel and random world, but the chaos is all so beautiful.”
― Hiromu Arakawa

@undefined @undefined I am able to make curved paths and object is able to follow its center both position and rotation. When I want to have object a bit left/right offset of path, it works great on straight path by just adding or subtract some offset from transform position.

But issue is when I offset object from center, then around curves the rotation of object becomes weird.

What calculation need to be followed for rotation of object along curve with left/right offset.

Advertisement

HunterXolo said:

@undefined @undefined I am able to make curved paths and object is able to follow its center both position and rotation. When I want to have object a bit left/right offset of path, it works great on straight path by just adding or subtract some offset from transform position.

But issue is when I offset object from center, then around curves the rotation of object becomes weird.

What calculation need to be followed for rotation of object along curve with left/right offset.

I would create an empty object as root, and then add the object proper which should be offset as a child.
Then just use the offset on you child object for the sideways displacement and have the root object follow the spline/path.

This way your rotations should be fine.

“It's a cruel and random world, but the chaos is all so beautiful.”
― Hiromu Arakawa

This topic is closed to new replies.

Advertisement