Question by
Ahapid · May 11, 2017 at 02:17 PM ·
rotationscripting problemeulerangles
transform.eulerAngles problem with parent rotation
i have a problem, if i rotate the parent, the rotation detection breaks.. i get 90 degrees or 270, it only works if i go into the minus, but then the limitation is broken. please help, thanks.
this is my script: void Update() {
Debug.Log(transform.GetChild(0).GetChild(0).GetChild(0).eulerAngles.y);
if (switchRotate == true)
{
if (TrackTarget == false)
{
if (Input.GetKey(upKey) && MaxAngle > transform.GetChild(0).GetChild(0).GetChild(0).eulerAngles.y)
{
transform.GetChild(0).GetChild(0).GetChild(0).Rotate(-Vector3.down);
}
if (Input.GetKey(downKey) && MinAngle < transform.GetChild(0).GetChild(0).GetChild(0).eulerAngles.y)
{
transform.GetChild(0).GetChild(0).GetChild(0).Rotate(-Vector3.up);
}
}
}
if (switchRotate == false)
{
if (TrackTarget == false)
{
if (Input.GetKey(upKey) && MaxAngle > transform.GetChild(0).GetChild(0).GetChild(0).eulerAngles.y)
{
transform.GetChild(0).GetChild(0).GetChild(0).Rotate(-Vector3.up);
}
if (Input.GetKey(downKey) && MinAngle < transform.GetChild(0).GetChild(0).GetChild(0).eulerAngles.y)
{
transform.GetChild(0).GetChild(0).GetChild(0).Rotate(-Vector3.down);
}
}
}
Comment
never$$anonymous$$d, fixed it.... i had to use local euler angles