dijital
1
Hi all,
Im playing with the unity car tutorial, its pretty good, but the car seems to fly off the track allot, be it on hills or because of crashes.
Is there a way to make the car ‘stick’ to the road?, it would give it a much more arcade feel.
Thanks in advance!
(also posted in scripting)
Eric5h5
2
This is not allowed; please read the Unity Developer Network rules (section 1b). I’ve deleted the duplicate.
–Eric
dijital
3
No matter, I just put the gravity up, now if I could just stop the car driving up the walls when its at full speed 
Lock some rotation axis on the rigidbody component or use mathf.clamp
function Update () {
var xMove : float = Input.GetAxis("Horizontal") * Time.deltaTime * 20;
transform.Translate(Vector3(xMove,0,0));
transform.position.x = Mathf.Clamp(transform.position.x, -10, 10);
}
This code comes with the videotutorial at unity3dstudent.com
http://www.unity3dstudent.com/2010/11/beginner-b26-using-mathf-clamp-to-restrict-values/
You would obviously need to clamp transform.rotation instead of transform.position
dijital
5
That sounds like exactly what I need, Thanks!