Hi there! I'm trying to make a space race idea and I need the vessel to stick to the track while moving. Is there a s script that can do this???
You can always raycast downwards and set its position to wherever the hit.point is. Getting the rotation right will be a little tougher, but using hit.normal and such can be used to solve that.
I am using the script below and the vessel keeps on jumping all over the place! Code (JavaScript): function Update () { var hit : RaycastHit; if (Physics.Raycast (transform.position, -Vector3.up, hit)) { var distanceToGround = hit.distance; //use below code if your pivot point is in the middle //transform.position.y = hit.distance - transform.GetComponent.<Collider>().bounds.extents; //use below code if your pivot point is at the bottom transform.position.y = hit.distance; } }