示例#1
0
    private void HeadBobIDLE()
    {
        affectedLocalY = transform.localPosition.y;

        if ((fpsController.GetIsSprinting() == false && fpsController.GetIsMovingForward() == false && fpsController.GetIsMovingBackward() == false &&
             fpsController.GetIsMovingLeft() == false && fpsController.GetIsMovingRight() == false &&
             fpsController.GetIsFalling() == false && fpsController.GetIsJumping() == false) || GameManager.instance.documentOpen || GameManager.instance.manualVisible)
        {
            //IDLE
            pauseCounter += Time.deltaTime;
            if (pauseCounter > 0.17) // time before start
            {
                transform.localPosition = new Vector3(transform.localPosition.x,
                                                      affectedLocalY + ((float)Mathf.Sin(Time.time * IDLEBobSpeed) * IDLEFloatStrength),
                                                      transform.localPosition.z);
            }
        }
        else if (transform.localPosition.y != originalLocalY)
        {
            pauseCounter = 0;
            if (transform.localPosition.y < originalLocalY && transform.localPosition.y > originalLocalY - 0.005f ||
                transform.localPosition.y > originalLocalY && transform.localPosition.y < originalLocalY + 0.005f)
            {
                transform.localPosition = new Vector3(transform.localPosition.x, originalLocalY, transform.localPosition.z);
            }
            if (transform.localPosition.y != originalLocalY)
            {
                if (transform.localPosition.y < originalLocalY)
                {
                    transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y + 0.006f, transform.localPosition.z);
                }
                else if (transform.localPosition.y > originalLocalY)
                {
                    transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y - 0.006f, transform.localPosition.z);
                }
            }
        }
    }