# Detecting when a car is out of the track

I am completely new to Unity 3D, just started to follow some tutorials y'day. I am trying to build a 2D car racing game as a part of my learning (time beating, no opponents). I have a racing track as texture (repeating). My problem is knowing when the car is outside/inside the track (I wouldn't prefer to limit it to the track boundaries).

What I have tried after searching around : I read somewhere about Mesh Colliders so:

• I added a mesh collider to the track (with 'Convex' and 'Is Trigger' checked , to be honest I don't know what Convex is, but I couldn't check 'Is Trigger' w/out checking 'Convex').

• Added OnTriggerExit and OnTriggerEnter methods to the Track script (the script that scrolls the track) hoping the two would be called each timer the car goes out of the track or gets back in.

• i would have a trigger placed outside the track, rather than being the track. sometimes unity runs into issues if you start the character model in the collider it wants to detect. So a simple test would be to put the car outside the track and have him come onto the track. – Ryan white Jan 17 '17 at 14:56
• For future reference, a "convex" collider uses the convex hull of the mesh for collisions. That means any crevices or concavities get flattened out, so the mesh has only flat regions and outward bulges, never inward, and has no holes or hollows — just one big blob. If I had a collider shaped like a hand, using its convex hull would turn it into a paddle. It's more efficient for collisions with complicated meshes with unimportant detail, but it's not what you want for representing all the bends and valleys in a race track. – DMGregory Sep 19 '17 at 11:44

If you just write OnTriggerEnter(){...} Or OnTriggerExit(){...} it won't work. You need a name for the Collider that triggered it. so for example OnTriggerEnter(Collider2D Player){...} Or OnTriggerExit(Collider2D Player){...}.