Example #1
0
    //Called to place a MovingColPoint to support moving colliders
    public override void PlaceMovingColPoint()
    {
        //MOVINGCOLPOINT, see CapsuleMovingColliderSolver for more details
        CEdgeCastInfo info = m_ControlledCollider.GetEdgeCastInfo();

        m_ControlledCollider.AddColPoint(info.GetEdgeTransform(), info.GetEdgePoint(), info.GetEdgeNormal());
    }
Example #2
0
    protected override void GeneratePath()
    {
        CEdgeCastInfo info = m_ControlledCollider.GetEdgeCastInfo();

        m_Path.Clear();
        CapsuleTransform copy = m_ControlledCollider.GetCapsuleTransformCopy();

        //First node is in edgehang alignment, moving away from the edge mildly
        CapsuleMovementPathNode newNode = m_Path.CreateFirstNode(copy);
        Vector3 upCenter = info.GetProposedHeadPoint();

        upCenter += m_ControlledCollider.GetEdgeCastInfo().GetWallNormal() * 0.03f;
        copy.SetUpCenter(upCenter);
        copy.Rotate(info.GetUpDirection(), RotateMethod.FromTop);
        newNode = m_Path.DuplicateAndAddLastNode();
        newNode.CopyFromTransform(copy);

        //Second node moves up along local up, until the bottom can slide over the edge
        newNode            = m_Path.DuplicateAndAddLastNode();
        newNode.m_Duration = m_MoveUpTime;
        float contactDot  = Vector3.Dot(info.GetEdgeNormal(), info.GetEdgePoint());
        float bottomDot   = Vector3.Dot(info.GetEdgeNormal(), copy.GetDownCenter()) - m_ControlledCollider.GetRadius() - m_MoveUpMargin;
        float normalDot   = Vector3.Dot(info.GetEdgeNormal(), copy.GetUpDirection());
        float rawDistance = contactDot - bottomDot;
        float distance    = rawDistance / normalDot;

        newNode.m_Position += copy.GetUpDirection() * distance;
        newNode.ApplyEntireMovement(copy);
        //Third node snaps the capsule to the "upright" position for the ground it's going to stand on
        newNode                = m_Path.DuplicateAndAddLastNode();
        newNode.m_Duration     = 0.0f;
        newNode.m_UpDirection  = (m_CharacterController.GetAlignsToGround()) ? info.GetEdgeNormal() : Vector3.up;
        newNode.m_RotateMethod = RotateMethod.FromBottom;
        newNode.ApplyEntireMovement(copy);
        newNode.m_Position = copy.GetPosition();
        //Final node moves the capsule over the ground
        newNode            = m_Path.DuplicateAndAddLastNode();
        newNode.m_Duration = m_MoveSideTime;
        Vector3 direction = CState.GetDirectionAlongNormal(-info.GetWallNormal(), info.GetEdgeNormal());

        newNode.m_Position += direction * m_MoveSideDistance;
        newNode.ApplyEntireMovement(copy);
    }
Example #3
0
    //Called whenever this module is started (was inactive, now is active)
    protected override void StartModuleImpl()
    {
        base.StartModuleImpl();
        //MOVINGCOLPOINT, see GroundedAnimatedAbilityModules for more details
        CEdgeCastInfo info = m_ControlledCollider.GetEdgeCastInfo();

        Transform transform = new GameObject().transform;

        transform.position = info.GetEdgePoint();
        transform.parent   = info.GetEdgeTransform();
        if (m_ReferencePoint == null)
        {
            m_ReferencePoint = new MovingColPoint();
        }
        m_ReferencePoint.m_Transform           = transform;
        m_ReferencePoint.m_PrevPoint           = transform.position;
        m_ReferencePoint.m_PrevRot             = transform.rotation;
        m_ReferencePoint.m_Normal              = info.GetEdgeNormal();
        m_ReferencePoint.m_PointRelativeToThis = m_ControlledCollider.GetCapsuleTransform().GetPosition() - info.GetEdgePoint();
    }