Beispiel #1
0
 void createTweenMove()
 {
     _degree    = Degree;
     _duration  = Duration;
     _direction = SwayDirection;
     _transform.localRotation = Quaternion.Euler(0, 0, _degree * (_direction == SwayDirection.Left ? 1 : -1));
     _transform.DOLocalRotateQuaternion(Quaternion.Euler(0, 0, _degree * (_direction == SwayDirection.Left ? -1 : 1)), _duration)
     .SetLoops(-1, LoopType.Yoyo)
     .SetEase(Ease.Linear)
     .SetId(gameObject);
 }
Beispiel #2
0
    private void UpdateSwaying(Vector3 curPos, Vector3 lastPos)
    {
        if (secondsElapsed > SwayCooldown)
        {
            SwayLeft.gameObject.SetActive(false);
            SwayRight.gameObject.SetActive(false);
            SwayMiddle.gameObject.SetActive(false);

            float xSway = curPos.x - lastPos.x;

            if (xSway < SwayThreshold)
            {
                currentSway = SwayDirection.Left;
                SwayLeft.gameObject.SetActive(true);
            }
            else if (xSway > -SwayThreshold)
            {
                currentSway = SwayDirection.Right;
                SwayRight.gameObject.SetActive(true);
            }
            else
            {
                currentSway = SwayDirection.Middle;
                SwayMiddle.gameObject.SetActive(true);
            }

            lastSway         = currentSway;
            timeInSwayState += secondsElapsed;
            secondsElapsed   = 0f;
        }

        if (timeInSwayState > SwayDuration)
        {
            SetState(UjelliState.Normal);
        }
    }