when i get off road get slower

i want when my car go out of track, get slower, i tried physical material, but i got nothing. my car is made by Unity3d Car Tutorial, so please help, i’m from Country Georgia, small country please help.

sry for my bad or good english

3 Answers

3

If there’s not a built-in way to check if you’re on track, you could do this: Set a bunch of plane colliders above the track and set them to trigger. Adjust the speed based on OnTriggerEnter and OnTriggerExit. Depending on how your velocity is working, you may need to make sure this doesn’t affect your car’s velocity if you get airborne and exit the trigger that way. Or perhaps it’ll be easier to put triggers along the sides of the track, and use those.

I’m not familiar with that particular tutorial, but there must be a way to know when the car is off track. At that point, set its velocity to be half of what it was. I’m guessing.

one thing i would try is to have a ray cast from the car pointing down to the ground and then test to see what the parent of the object hit is. then you could have all of your track in one game object root named track or something, and your different terrains in another game object,

then from that you could just simple say if hit is equal to terrain then reduce your speed or any other settings you have, and then if its on track put them back up.

i would only check your ray once a second though, and probably store the parent object as a variable boolean, and then your not changing your cars settings every second, your just checking to see if the boolean has changed.

this is all theory though but should work