Ejemplo n.º 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        if (isLocalPlayer)
        {
            Vector3 groundVelocity = movementController.GetGroundedVelocity();
            if (groundVelocity.magnitude >= aSmallValue)
            {
                SetFaceDirection(Mathf.Rad2Deg * Mathf.Atan2(-groundVelocity.z, groundVelocity.x));
            }
            //if (false && movementController.GetMoveState () != MoveState.rolling) {
            //	Vector3 cameraDirection = movementController.InCameraDirection (Vector3.forward);
            //	SetFaceDirection (Mathf.Rad2Deg * Mathf.Atan2 (-cameraDirection.z, cameraDirection.x));
            //	Vector3 moveDirection = movementController.OutOfCameraDirection (movementController.GetGroundedVelocity ().normalized);
            //	if (moveDirection.z >= -.1f)
            //		animator.SetFloat ("VelCompX", moveDirection.x);
            //	else
            //		animator.SetFloat ("VelCompX", -moveDirection.x);


            //}
            Vector3 accTilt = movementController.GetAccelerationDirection();
            if (movementController.GetMoveState() == MoveState.gliding)
            {
                armatureTilt.localRotation = Quaternion.Euler(accTilt.z * maxTiltGlide, 0, -accTilt.x * maxTiltGlide);
            }
            else
            {
                armatureTilt.localRotation = Quaternion.Euler(accTilt.z * maxTilt, 0, -accTilt.x * maxTilt);
            }

            animator.SetInteger("MoveState", (int)movementController.GetMoveState());
            //Debug.Log ((int)movementController.GetMoveState ());
            animator.SetFloat("Velocity", groundVelocity.magnitude);
            animator.SetFloat("Jump", -movementController.GetVelocity().y / (movementController.initialJumpPower + movementController.maxJumpPowerAdd / 2.5f));
            animator.SetFloat("Flapping", movementController.GetFlapping());

            CmdSyncData(faceDirAngle);
        }

        armatureFaceVel.localRotation = Quaternion.Euler(new Vector3(0, 90 + faceDirAngle, 0));

        invincibleFlash.TryUpdate(playerMain.invincible);

        //armRotation.x = 90 * accTilt.z;
        //armRotation.z = 90 * accTilt.x;
    }