コード例 #1
0
 public void onStanceChanged(BodyStance s)
 {
     currentStance = stanceManager.CurrentStanceData();
 }
コード例 #2
0
        public BattlePlayerMovementState Move(Vector3 move, float turnAmount, BodyStance stance, bool jump)
        {
            var moveState = new BattlePlayerMovementState();

            if (!started)
            {
                return(null);
            }
            // convert the world relative moveInput vector into a local-relative
            // turn amount and forward amount required to head in the desired
            // direction.
            CheckGroundStatus();

            var speedFactor = m_MoveSpeedMultiplier;

            speedFactor *= currentStance.SpeedFactor;
            if (currentStance.StickToGroundAngle) //TODO make a 'myNormal' for the character, break out this code
            {
                var oldMove = move;
                move = Vector3.ProjectOnPlane(move, m_GroundNormal);
                var uphill    = oldMove.y < move.y;
                var moveSlope = Vector3.Angle(oldMove, move);
                if (uphill && moveSlope > 5)
                {
                    speedFactor *= currentStance.AngleSpeedAdjust * moveSlope;
                }

                /*
                 * var sign = (!uphill ? "-" : "+");
                 * Debug.Log("angle is "+ sign+ " " + moveSlope.ToString());
                 */
                Debug.DrawLine(transform.position, transform.position + move * 5, Color.red);
            }


            m_Rigidbody.velocity = new Vector3(move.x * speedFactor, m_Rigidbody.velocity.y, move.z * speedFactor);
            moveState.Velocity   = m_Rigidbody.velocity;

            move            = transform.InverseTransformDirection(move);
            m_ForwardAmount = move.z;
            m_TurnAmount    = turnAmount * m_CursorSensitivity;
            m_StrafeAmount  = move.x;
            moveState.Move  = move;

            ApplyExtraTurnRotation();
            bool crouch = stance == BodyStance.Crouch;

            m_stance         = stance;
            moveState.Stance = stance;
            // control and velocity handling is different when grounded and airborne:
            if (m_IsGrounded)
            {
                HandleGroundedMovement(crouch, jump);
                moveState.Grounded = true;
            }
            else
            {
                HandleAirborneMovement();
                moveState.Grounded = false;
            }

//            ScaleCapsuleForCrouching(crouch);
//            PreventStandingInLowHeadroom();

            // send input and other state parameters to the animator
            UpdateAnimator(move);
            return(moveState);
        }
コード例 #3
0
 protected void SetInputs(Vector3 m, float t, int c)
 {
     //Debug.LogFormat("{0} setting inputs m:{1}", tno.owner.name, m);
     m_Move = m; m_TurnAmount = t;  m_stance = (BodyStance)c;
 }