コード例 #1
0
        private void Update()
        {
            Vector3 currentRotation = transform.localEulerAngles;

            float horizontalViewAxis = InputSplitter.GetHorizontalViewAxis(fpsMove.PlayerID);
            float deltaRotationY     = horizontalViewAxis * Sensitivity;
            float rotationY          = currentRotation.y + deltaRotationY;

            transform.localEulerAngles = new Vector3(currentRotation.x, rotationY, currentRotation.z);
        }
コード例 #2
0
        private void Update()
        {
            Vector3 currentRotation = transform.localEulerAngles;

            float verticalViewAxis = InputSplitter.GetVerticalViewAxis(fpsMove.PlayerID);
            float deltaRotationX   = verticalViewAxis * Sensitivity;

            currentAngle -= deltaRotationX;
            currentAngle  = Mathf.Clamp(currentAngle, MinimumAngle, MaximumAngle);

            transform.localEulerAngles = new Vector3(currentAngle, currentRotation.y, currentRotation.z);
        }
コード例 #3
0
        private void Update()
        {
            movementZ = InputSplitter.GetVerticalAxis(PlayerID);
            movementX = InputSplitter.GetHorizontalAxis(PlayerID);
            if (InputSplitter.GetSlidePressed(PlayerID))
            {
                shouldSlide = true;
            }

            if (InputSplitter.GetJumpPressed(PlayerID))
            {
                shouldJump = true;
            }
        }
コード例 #4
0
        private void UpdateSlideMotion()
        {
            float   movementZ  = 1.0f;
            float   movementX  = InputSplitter.GetHorizontalAxis(PlayerID);
            Vector3 moveVector = new Vector3(movementX, 0, movementZ);

            if (moveVector != Vector3.zero)
            {
                float moveMagnitude = moveVector.magnitude;
                moveVector   /= moveMagnitude;
                moveMagnitude = Mathf.Min(1.0f, moveMagnitude);

                moveVector = (transform.rotation * moveVector) * RunSpeed * moveMagnitude;
            }

            velocity.x = moveVector.x;
            velocity.z = moveVector.z;

            // Apply Gravity
            velocity.y -= 9.81f * Time.fixedDeltaTime;

            // Actually move
            // TODO: Check new velocity after update, we might need to exit slide (e.g if we slide into a wall)
            MoveAndUpdateVelocity();

            if (charController.isGrounded)
            {
                velocity.y = 0.0f;
            }

            // Apply sliding slowdown
            RunSpeed -= SlideDeceleration * Time.fixedDeltaTime;

            // We should stop sliding if we are either:
            //  1) No longer moving fast enough to warrant a slide
            //  2) No longer holding down the slide key
            bool shouldStopSlide = false;

            shouldStopSlide = shouldStopSlide || (RunSpeed < SlideStopSpeedThreshold);
            shouldStopSlide = shouldStopSlide || (!InputSplitter.GetSlide(PlayerID));
            if (shouldStopSlide)
            {
                headBob.enabled = true;

                currentMotion = DefinedMotion.NONE;
                SetAnimBool(animParamSlide, false);
                RunSpeed = DefaultRunSpeed;
            }
        }
コード例 #5
0
 internal void Update()
 {
     if (Enabled)
     {
         if (currentLocation + 1 != Locations.Length)
         {
             ApplyCameraLerp();
         }
         if (!runClose && currentLocation + 1 == Locations.Length)
         {
             fadeController.KillPlayer();
             runClose = true;
         }
         if (runClose)
         {
             if (fadeController.FadeoutAlpha > 0.99f)
             {
                 IntroDialog.Stop();
                 this.gameObject.camera.enabled = false;
                 foreach (GameObject cameraObj in playerCameras)
                 {
                     cameraObj.camera.enabled = true;
                 }
                 playerOneLifeHander.BlackToClear();
                 playerTwoLifeHander.BlackToClear();
                 //fadeController.enabled = false;
             }
             if (playerOneLifeHander.FadeoutAlpha > 0.99f && playerTwoLifeHander.FadeoutAlpha > 0.99f && !CountDownTimer.IsActive)
             {
                 CountDownTimer.IsActive = true;
             }
             else if (playerOneLifeHander.FadeoutAlpha < 0.05f && playerTwoLifeHander.FadeoutAlpha < 0.05f && CountDownTimer.Finished)
             {
                 EnablePlayerMode();
             }
         }
         for (int i = 0; i < PopUpMessageStart.Length; ++i)
         {
             if (currentLocation == PopUpMessageStart[i])
             {
                 if (popUpMessageCanvas[i].alpha < 1.0f)
                 {
                     popUpMessageCanvas[i].alpha += Time.deltaTime * 1;
                 }
             }
         }
         for (int i = 0; i < PopUpMessageEnd.Length; ++i)
         {
             if (currentLocation == PopUpMessageEnd[i])
             {
                 if (popUpMessageCanvas[i].alpha > 0.0f)
                 {
                     popUpMessageCanvas[i].alpha -= Time.deltaTime * 1;
                 }
             }
         }
     }
     if (Enabled && !runClose && (InputSplitter.GetJumpPressed(0) || InputSplitter.GetJumpPressed(1)))
     {
         fadeController.KillPlayer();
         runClose = true;
     }
 }