示例#1
0
    public Vector2 GetDirectedInputMovement()
    {
        CGroundedInfo groundedInfo = m_ControlledCollider.GetGroundedInfo();

        if (groundedInfo.m_IsGrounded)
        {
            Vector2 input = groundedInfo.GetWalkDirection(new Vector2(transform.right.x, transform.right.y) * GetInputMovement().x);
            return(Vector2.ClampMagnitude(input, Vector2.Dot(input.normalized, GetInputMovement())));
        }
        return(new Vector2(GetInputMovement().x, 0));
    }
示例#2
0
    public Vector2 GetFriction(Vector2 a_Velocity, Vector2 a_CurrentForce, float a_FrictionConstant)
    {
        if (m_ControlledCollider.IsGrounded())
        {
            CGroundedInfo groundedInfo = m_ControlledCollider.GetGroundedInfo();

            Vector2 direction = -groundedInfo.GetWalkDirection(a_Velocity); //Opposite direction of velocity
            Vector2 maxFrictionSpeedChange = direction * a_FrictionConstant * Time.fixedDeltaTime;

            Vector2 velInDirection = Mathf.Abs(Vector2.Dot(a_Velocity, direction)) * direction;
            if (velInDirection.magnitude > maxFrictionSpeedChange.magnitude)
            {
                return(maxFrictionSpeedChange);
            }
            else
            {
                return(velInDirection);
            }
        }
        return(Vector2.zero);
    }