I want the object to rotate only on z. To keep x and y and changing z to 0.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Whilefun.FPEKit;
public class PlayAnimation : MonoBehaviour
{
public List<GameObject> cameras = new List<GameObject>();
public GameObject head;
private Animator anim;
private bool started = true;
private float animationLenth;
private bool rotateHead = false;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
}
private void Update()
{
if (FPESaveLoadManager.gameStarted == true && started == true)
{
FPEInteractionManagerScript.Instance.BeginCutscene();
anim.enabled = true;
anim.Play("Stand Up", 0, 0);
animationLenth = anim.GetCurrentAnimatorStateInfo(0).length;
StartCoroutine(AnimationEnded());
started = false;
}
if(rotateHead == true)
{
head.transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(transform.rotation.x, transform.rotation.y, 0f), 1.0f * Time.deltaTime);
}
}
IEnumerator AnimationEnded()
{
yield return new WaitForSeconds(animationLenth);
anim.enabled = false;
FPEInteractionManagerScript.Instance.EndCutscene();
rotateHead = true;
}
}
I'm trying to rotate the head. When the animation is end the head rotation is : X = -9.922001 Y = 6.804 Z = 4.167
When the rotation of the head is ending or maybe it's never ending since it's in the update ? The head rotation is : X = -4.529 Y = -9.392 Z = 0.988 Why x and y change and z never get to 0 ?
Another strange thing I saw now the position of the transform on X when the animation is ended is -5.089218e-12 what is this e-12 ?