I’m having some difficulty returning a weapon object back to its original rotation values.
on mouse click im rotating the object, then on mouse lift i want to return to its starting position. However, no matter what i tried the rotation values change every click, and even sometimes reset to 0,0,0.
private Transform weaponTransform;
public Quaternion weaponOriginalLocation;
void Start(){
weaponOriginalLocation = transform.rotation;
}
void Update(){
if (Input.GetMouseButtonDown(0)){
weaponTransform.transform.localRotation = Quaternion.Slerp(weaponTransform.localRotation, Quaternion.Euler(100f, 0f, 0f),0.5f);
}
if (Input.GetMouseButtonUp(0)){
weaponTransform.transform.localRotation = Quaternion.Slerp(weaponTransform.localRotation, weaponOriginalLocation, Time.deltaTime * speed);
Debug.Log("Rotation: " + weaponTransform.transform.localRotation);
}
}
Rotation: (0.5,0.0,0.8)
Rotation: (0.7,0.0,0.7)
I’ve tried eularAngles, vector/quaternion. Nothing i do works.
the Original Rotation should be: (14.5,0,0)