- Home /
Two scripts rotating the same object
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 :)
Answer by Safforn · Mar 30, 2015 at 09:42 AM
Try putting one of these in a LateUpdate() function.
Tried it . didn't work . it rotates a little bit and then snaps back (as i expected it to)
Your answer
Follow this Question
Related Questions
How to smoothly align an object to a surface, but only partially 2 Answers
combine / convert rotations (Quaternion and Vector3) 1 Answer
how to combine 2 quaternion components? 2 Answers
Combining two Quaternion Slerps on an object 1 Answer
Calculate rotation angle for two side of cube ( like dice ) from Quaternion.identity 0 Answers