How To Know If You Are On Track (Top Down 2D Racer Track)

Hi there,
If you were to develop a top down, 2D racing game in unity, where the player must know if it is on or off the track, how would you do this?

Currently I think my best option is to create the track pieces in Illustrator, port to Blender as svg and apply a Mesh Collider to the models. This would give me a precise collider at each track segment.

That said, I am wondering about alternatives, in terms of performance to the engine.

Any ideas?
Thanks

I think collision serving as “triggers” would work just fine in this scenario. You can easily check when the player is within the bounds of a specific shape, or outside of it. You can also use the more optimized 2D collider shapes as well.

I think Unity’s new 2d tools let you create this kind of geometry in the editor.

1 Like

Yes they sure do. This is what you’d be looking for:
https://docs.unity3d.com/Manual/class-PolygonCollider2D.html

1 Like

Wow. Did not know it existed.

1 Like