I felt this was a better place to ask this, rather than the forums. Ok, so I have a car that I can move around and I need it to align itself to the ground normals for a Mario Kart/Little Big Planet Kart type of physics. The script I have has some problems. Whenever it “aligns” me to the ground normals it sets my Y rotation to the specific rotation every time. It also doesn’t align me often enough. It usually only works when I go up and down slopes. It is in the Update, so that’s not the problem.
Here is my script so far:
var hit : RaycastHit;
var castRot = Vector3(transform.position.x,transform.position.y-.50,transform.position.z);
if (Physics.Raycast (castRot, -transform.up, hit)) {
transform.rotation = Quaternion.FromToRotation (Vector3.up, hit.normal);
}
Does anybody have an idea of what is wrong?