I have a car with two scripts attached to it , one scripts handles the steering while the other one rotates it to the ground normal vector , when i try to steer it though the car does align itself with the ground but it’s steering remains still . Here’s the steering script :
if(Input.GetKey(KeyCode.D))
{
this.transform.Rotate (Vector3.up*Time.deltaTime*steerAmount);
}
if(Input.GetKey(KeyCode.A))
{
this.transform.Rotate (-Vector3.up*Time.deltaTime*steerAmount);
}
And there is the aligning script :
if(Physics.Raycast(this.transform.position,-this.transform.up,out hit,2034.0f))
{
this.transform.up = Vector3.Slerp(this.transform.up,hit.normal,Time.deltaTime);
}
Now i know i have to find a way to combine these two rotations but i can’t find one yet . Thanks for your time