//Check if the entire path can be applied public bool IsPossible(CapsuleTransform a_Transform) { CapsuleTransform transform = a_Transform.CreateCopy(); bool isPossible = true; for (int i = 0; i < m_PathNodes.Count; i++) { //if (m_PathNodes[i].CanApplyEntireMovement(transform)) { m_PathNodes[i].ApplyEntireMovement(transform); } //else { // return false; } } if (!transform.CanExistHere()) { return(false); } return(isPossible); }
//Called for every fixedupdate that this module is active public override void FixedUpdateModule() { float currentTransitionTime = Time.time - m_TransitionStartTime; //A MovingColPoint is used to move and rotate the animation path when the collider it starts on is moved //This allows animated abilities to work on moving colliders if (m_ReferencePoint != null) { //Position CapsuleTransform copy = m_ControlledCollider.GetCapsuleTransformCopy(); Vector3 diff = m_ReferencePoint.m_Transform.position - m_ReferencePoint.m_PrevPoint; copy.Move(diff); m_Path.Move(diff); //Rotation Quaternion rotationDifference = Quaternion.FromToRotation(m_ReferencePoint.m_PrevRot * Vector3.up, m_ReferencePoint.m_Transform.rotation * Vector3.up); copy.Rotate(rotationDifference * copy.GetUpDirection(), RotateMethod.FromCenter); m_Path.Rotate(rotationDifference, m_ReferencePoint.m_PrevPoint); //Offset for rotation Vector3 newRelativePoint = rotationDifference * m_ReferencePoint.m_PointRelativeToThis; Vector3 relativeDifference = newRelativePoint - m_ReferencePoint.m_PointRelativeToThis; copy.Move(relativeDifference); m_ReferencePoint.m_PrevPoint = m_ReferencePoint.m_Transform.position; m_ReferencePoint.m_PrevRot = m_ReferencePoint.m_Transform.rotation; m_ReferencePoint.m_PointRelativeToThis = m_ReferencePoint.m_Transform.position - m_ControlledCollider.GetCapsuleTransform().GetPosition(); m_ReferencePoint.m_Normal = Quaternion.FromToRotation(m_ReferencePoint.m_PrevRot * Vector3.up, m_ReferencePoint.m_Transform.rotation * Vector3.up) * m_ReferencePoint.m_Normal; if (copy.CanExistHere()) { m_ControlledCollider.ApplyCapsuleTransform(copy); } else { m_WasInterrupted = true; return; } } m_ControlledCollider.SetVelocity(Vector2.zero); //Move along the nodes as long as they can be applied (either they are finished or their duration is 0) while (!m_Path.IsDone() && m_Path.m_CurrentPathNode != null && (m_Path.m_CurrentPathNode.m_Duration == 0 || Time.time - m_TransitionStartTime >= m_Path.m_CurrentPathNode.m_Duration)) { if (m_Path.m_CurrentPathNode.CanApplyEntireMovement(m_ControlledCollider.GetCapsuleTransform())) { m_TransitionStartTime += m_Path.m_CurrentPathNode.m_Duration; currentTransitionTime -= m_Path.m_CurrentPathNode.m_Duration; m_Path.m_CurrentPathNode.ApplyEntireMovement(m_ControlledCollider.GetCapsuleTransform()); m_Path.IncrementCurrentNode(); } else { m_WasInterrupted = true; return; } } //Move along the current node if (m_Path.CanApplyMotion(m_ControlledCollider.GetCapsuleTransform(), currentTransitionTime)) { m_Path.ApplyMotion(m_ControlledCollider.GetCapsuleTransform(), currentTransitionTime); } else { m_WasInterrupted = true; return; } m_ControlledCollider.UpdateContextInfo(); }