//Query whether this module can be active, given the current state of the character controller (velocity, isGrounded etc.) //Called every frame when inactive (to see if it could be) and when active (to see if it should not be) public override bool IsApplicable() { if (!m_IsActive) { //Character can't touch ground, has to touch edge and might be disabled if it is moving upwards if (m_ControlledCollider.IsGrounded()) { return(false); } if (!m_ControlledCollider.IsTouchingEdge()) { return(false); } CEdgeCastInfo info = m_ControlledCollider.GetEdgeCastInfo(); if (GetDirInput("Move").m_Direction == DirectionInput.Direction.Up || GetDirInput("Move").IsInThisDirection(-info.GetWallNormal())) { float angle = Vector3.Angle(info.GetEdgeNormal(), Vector3.up); if (angle >= m_ControlledCollider.GetMaxGroundedAngle()) { return(false); } GeneratePath(); if (m_Path.IsPossible(m_ControlledCollider.GetCapsuleTransform())) { return(true); } } } else { //If the referencepoint slope is too steep to cling on to (during motion), interrupt movement float angle = Vector3.Angle(m_ReferencePoint.m_Transform.up, Vector3.up); if (angle >= m_ControlledCollider.GetMaxGroundedAngle()) { return(false); } if (m_WasInterrupted) { return(false); } if (Time.time - m_StartTime >= m_Path.GetTotalTime() || m_Path.IsDone()) { return(false); } return(true); } return(false); }
//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(); }
//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()); }