Exemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     GetInput();
     BowCamera();
     // If Player is running and not looking for certain amount of time.
     if (vOrbitInput == 0 && hOrbitInput == 0 && playerStateManager.GetPlayerPose(true) == scr_PSM.PlayerPose.pose_running)
     {
         cameraReturnCounter += Time.deltaTime;
         if (cameraReturnCounter > m_cameraPositionSettings.m_CameraReturnTime)
         {
             m_returnCamera     = true;
             m_CameraIsOrbiting = false;
         }
     }
     //if player is looking
     else if (vOrbitInput != 0 && hOrbitInput != 0)
     {
         cameraReturnCounter = 0;
         OrbitTarget();
     }
     //if player is starting to move forward and player angle != camera angle.
     else if (playerStateManager.GetPlayerPose(true) == scr_PSM.PlayerPose.pose_idle && transform.rotation != m_charController.transform.rotation)
     {
     }
 }
Exemplo n.º 2
0
    void ClimbingJump()
    {
        if (m_psm.GetPlayerPose(true) == scr_PSM.PlayerPose.pose_wallclimbing && CrossPlatformInputManager.GetButtonDown("Jump"))
        {
            var localVel = transform.InverseTransformDirection(m_rgd.velocity);
            localVel.z = 1;
            localVel.y = 7;

            m_rgd.velocity = transform.TransformDirection(localVel);
            m_psm.SetPlayerPose(scr_PSM.PlayerPose.pose_running);
        }
    }
 void Turn()
 {
     if (playerStateManager.GetPlayerPose(true) == scr_PSM.PlayerPose.pose_idle)
     {
         //TurnCharacterToCameraRotation();
         //m_targetRotation *= Quaternion.AngleAxis(m_moveSettings.m_RotationSpeed * turnInput * Time.deltaTime, Vector3.up);
     }
     if (playerStateManager.GetPlayerPose(true) == scr_PSM.PlayerPose.pose_running)
     {
         m_targetRotation *= Quaternion.AngleAxis(m_moveSettings.m_RotationSpeed * turnInput * Time.deltaTime, Vector3.up);
     }
     transform.rotation = m_targetRotation;
 }
Exemplo n.º 4
0
    public void Move(Vector3 move, bool crouch, bool jump, bool sliding, bool climbing, Vector3 lookPos, bool aim)
    {
        // convert the world relative moveInput vector into a local-relative
        // turn amount and forward amount required to head in the desired
        // direction.

        if (move.magnitude > 1f)
        {
            move.Normalize();
        }
        move = transform.InverseTransformDirection(move);
        CheckGroundStatus();
        move                     = Vector3.ProjectOnPlane(move, m_GroundNormal);
        m_TurnAmount             = Mathf.Atan2(move.x, move.z);
        m_ForwardAmount          = move.z;
        m_Left                   = move.x;
        this.isAiming            = aim;
        this.isSliding           = sliding;
        this.currentLookPosition = lookPos;
        this.isClimbing          = climbing;
        if (!isAiming && m_PSM.GetPlayerState(true) == scr_PSM.Playerstate.state_grounded)
        {
            ApplyExtraTurnRotation();
        }
        else if (isAiming)
        {
            // m_Player.transform.forward = Camera.main.transform.forward;
            //
            m_Player.transform.forward = new Vector3(Camera.main.transform.forward.x, m_Player.transform.forward.y, Camera.main.transform.forward.z);
        }
        Sliding();
        // control and velocity handling is different when grounded and airborne:
        if (m_IsGrounded)
        {
            HandleGroundedMovement(crouch, jump);
            m_PSM.SetPlayerState(scr_PSM.Playerstate.state_grounded);
            m_PSM.SetPlayerPose(scr_PSM.PlayerPose.pose_running);
        }
        else if (m_PSM.GetPlayerPose(true) != scr_PSM.PlayerPose.pose_wallclimbing)
        {
            HandleAirborneMovement();
            m_PSM.SetPlayerState(scr_PSM.Playerstate.state_airborne);
        }
        ScaleCapsuleForCrouching(crouch);
        PreventStandingInLowHeadroom();
        JumpHandler();
        // send input and other state parameters to the animator
        UpdateAnimator(move);
    }