public bool CanApplyEntireMovement(CapsuleTransform a_Transform)
 {
     if (a_Transform.GetPosition() != m_Position)
     {
         if (!a_Transform.CanMove(m_Position - a_Transform.GetPosition(), true))
         {
             return(false);
         }
     }
     if (a_Transform.GetUpDirection() != m_UpDirection)
     {
         if (!a_Transform.CanRotate(m_UpDirection, m_RotateMethod))
         {
             return(false);
         }
     }
     if (a_Transform.GetLength() != m_Length)
     {
         if (!a_Transform.CanBeResized(m_Length, m_ResizeMethod))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 2
0
//Main movement update
//Used by CharacterControllerBase to move the collider and update its velocity in the process
//This will collide against geometry and take appropriate action
    public override void UpdateWithVelocity(Vector2 a_Velocity)
    {
#if UNITY_EDITOR
        //If the length has been edited in the inspector since last update, see if the capsule transform needs to be updated
        if (m_Length != m_PrevLength)
        {
            if (m_PrevLength == m_CapsuleTransform.GetLength())
            {
                m_CapsuleTransform.SetLength(m_Length, CapsuleResizeMethod.FromBottom);
            }
            m_PrevLength = m_Length;
        }
#endif
        //The character may have been moved, either via script or via editor. Adjust position to make up for this
        CheckForUpdatedPosition();

        Vector3 realVel = new Vector3(a_Velocity.x, a_Velocity.y, 0) * Time.fixedDeltaTime;
        m_Collisions.Clear();
        if (m_CollisionsActive)
        {
            TryMove(realVel, ref a_Velocity);
        }
        else
        {
            m_CapsuleTransform.Move(realVel);
        }

        m_PrevVelocity = m_Velocity;
        m_Velocity     = a_Velocity;

        UpdateContextInfo();

        //MOVINGCOLPOINT, see CapsuleMovingColliderSolver for more details
        if (IsGrounded())
        {
            AddColPoint(m_State.m_GroundedInfo.GetGroundTransform(), m_State.m_GroundedInfo.GetPoint(), m_State.m_GroundedInfo.GetNormal());
        }
    }
 public void ApplyEntireMovement(CapsuleTransform a_Transform)
 {
     if (a_Transform.GetPosition() != m_Position)
     {
         a_Transform.SetPosition(m_Position);
     }
     if (a_Transform.GetUpDirection() != m_UpDirection)
     {
         a_Transform.Rotate(m_UpDirection, m_RotateMethod);
     }
     if (a_Transform.GetLength() != m_Length)
     {
         a_Transform.SetLength(m_Length, m_ResizeMethod);
     }
 }
 public void CopyFromTransform(CapsuleTransform a_Transform)
 {
     m_Position    = a_Transform.GetPosition();
     m_UpDirection = a_Transform.GetUpDirection();
     m_Length      = a_Transform.GetLength();
 }