- Home /
Quaternion.Lerp messing up after being deactived and then activated again
Hey everybody!
I have a gun script that automatically makes the gun face the camera. Everything runs fine, but when i reactivate again (after hours of narrowing down the problem), the lerp function goes haywire and makes the gun start rolling on the x axis when the player starts moving.
//get our position
transform.position = Vector3.Lerp(transform.position, GameObject.FindGameObjectWithTag(tagOfWeaponLocation).transform.position, 0.99f);
//get our rotation if we're not firing the weapon
if(GetComponent<WeaponFire>().beingFired == false)
{
transform.rotation = Quaternion.Lerp(transform.rotation, GameObject.FindGameObjectWithTag(tagOfCamera).camera.transform.rotation, 0.433f);
Debug.Log(Quaternion.Lerp(transform.rotation, GameObject.FindGameObjectWithTag(tagOfCamera).camera.transform.rotation, 0.433f));
}
Thanks for any insight/help, Nikita
Answer by nikita68 · May 27, 2013 at 12:55 PM
Doesn't matter. Solved by making the gun a child of a different object.
incase this is a problem in the future, Quaternion.RotateTowards is what i suggest
Your answer
Follow this Question
Related Questions
how to make a first person controller shooting a target? 0 Answers
How can I make a gun automatic? 2 Answers
Quaternion rotation not behaving as intended 1 Answer
Rotating an object around Z axis using Lerp 2 Answers
gun crashing 1 Answer