Hello, before i proceeding here i already searched the best solution but i couldnt solve the problem.
I have a main character(child) that belongs to main character object(parent) (they are equivalent on name only, pardon for confusing), i need to rotate the child main character so it is facing to left, right, forward backward same as god of war if you know it.
my problem is i cant set the exact value for child main character’s rotation y axis and it gave weird value. if i set the y axis to 90 degree the debug.log method shows the value of decimal numbers such as 0.7000… something. If i look the child’s transform rotation it displayed not exactly like 90 but more than 90.
Im already confused.
I dont know how to solve this kind of issue since im still a beginner.
ill show you my code,
public float rightValue = 0.0f;
private GameObject childPlayer;
void Start ()
{
childPlayer = GameObject.FindGameObjectWithTag("Child Player");
}
void Update ()
{
if (Input.GetKey(KeyCode.W))
{
rightValue = 90.0f;
if (rightValue >=90.0f)
{
childPlayer.transform.localRotation = Quaternion.Slerp(Quaternion.identity, new Quaternion(0, rightValue, 0, 0), .5f);
childPlayer.animation.CrossFade("idle Run Forward");
}
else
{
}
}
else
{
childPlayer.animation.CrossFade("idle 01");
}
}
Please help me. Thank you in advance
Im using the CharacterController class to control the main character parent.