Quaternion.Lerp SUPER laggy/freezing.
Hello, i was searching for how to make 1 object rotate to the rotation of another and found Quaternion.Lerp, which seems to work somewhat, but it suddenly freezes and stops rotating, recorded it so you can see: https://youtu.be/XXbrHheBKrQ
sometimes it works just fine for 10-15 seconds, sometimes it just lags, sometimes it just totally stops following the rotation.
the script im using is:
public GameObject Char;
public GameObject Player;
public Rigidbody RB;
public float TurnSpeed;
// Use this for initialization
void Start () {
Char = GameObject.FindGameObjectWithTag("Char");
Player = GameObject.FindGameObjectWithTag("Player");
RB = Char.transform.GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate () {
if(Player.transform.rotation.x > Char.transform.rotation.x)
{
Char.transform.rotation = Quaternion.Lerp(transform.rotation, Player.transform.rotation, Time.deltaTime * TurnSpeed);
}
}
purpose for this is to make a person in space aim, and then the char turning around to match the aim, but not instantly, for a space shooter game.
Your answer
Follow this Question
Related Questions
How to reset the object's rotation to (0,0,0)? 1 Answer
How to make a Child object(camera) ignore its Parent Object's rotaton? 1 Answer
when trying to rotate, the object transforming itself 0 Answers
How to change the direction of the model? 1 Answer
Rotate an Object while moving forward using empty gameObject 0 Answers