Search Unity

Two Vector3 values comparison using coroutine

Discussion in 'VR' started by Kideokk, Jun 19, 2018.

  1. Kideokk

    Kideokk

    Joined:
    Jan 18, 2018
    Posts:
    31
    hi, everyone.
    i'm doing two rotation(vector3) values comparison, but sometime it is not matched. and i'm using coroutine.
    here is my code
    Code (CSharp):
    1. if (!Mathf.Approximately(targetObjectRotation.x, currentObjectRotation.x))
    2.             currentObjectRotation.x += (differenceObjectRotation.x / 30f);
    3. else
    4.             isCorrectX = true;
    5.  
    6. if (!Mathf.Approximately(targetObjectRotation.y, currentObjectRotation.y))
    7.             currentObjectRotation.y += (differenceObjectRotation.y / 30f);
    8. else
    9.             isCorrectY = true;
    10.  
    11. if (!Mathf.Approximately(targetObjectRotation.z, currentObjectRotation.z))
    12.             currentObjectRotation.z += (differenceObjectRotation.z / 30f);
    13. else
    14.             isCorrectZ = true;
    sometime one of three value is incorrect. so occur infinity loop. how do i that?
     
  2. Kideokk

    Kideokk

    Joined:
    Jan 18, 2018
    Posts:
    31
    i found this problem's solution. i'm just added code
    Code (CSharp):
    1. if (!Mathf.Approximately(targetObjectRotation.x, currentObjectRotation.x) && Mathf.Abs(targetObjectRotation.x - currentObjectRotation.x) > 0.5f)
    i don't know it is helpful or correct method.
    :)