/// <summary> /// Play a sequence of actions! /// </summary> public void PlayAction(ref ActionRequestData action) { //the character needs to be alive in order to be able to play actions if (NetState.NetworkLifeState.Value == LifeState.Alive && !m_Movement.IsPerformingForcedMovement()) { if (action.CancelMovement) { m_Movement.CancelMove(); } m_ActionPlayer.PlayAction(ref action); } }
/// <summary> /// Called each frame while the action is running. /// </summary> /// <returns>true to keep running, false to stop. The Action will stop by default when its duration expires, if it has a duration set. </returns> public override bool Update() { if (StopIfDone()) { return(ActionConclusion.Stop); } // Keep re-assigning our chase target whenever possible. // This way, if we get Knocked Back mid-chase, we pick right back up and continue the chase. if (!m_Movement.IsPerformingForcedMovement()) { m_Movement.FollowTransform(m_Target.transform); } return(ActionConclusion.Continue); }
/// <summary> /// Called when the Action starts actually playing (which may be after it is created, because of queueing). /// </summary> /// <returns>false if the action decided it doesn't want to run after all, true otherwise. </returns> public override bool Start() { if (!HasValidTarget()) { Debug.Log("Failed to start ChaseAction. The target entity wasn't submitted or doesn't exist anymore"); return(ActionConclusion.Stop); } m_Target = NetworkSpawnManager.SpawnedObjects[m_Data.TargetIds[0]]; m_Movement = m_Parent.GetComponent <ServerCharacterMovement>(); Vector3 currentTargetPos = m_Target.transform.position; if (StopIfDone()) { m_Parent.transform.LookAt(currentTargetPos); //even if we didn't move, snap to face the target! return(ActionConclusion.Stop); } if (!m_Movement.IsPerformingForcedMovement()) { m_Movement.FollowTransform(m_Target.transform); } return(ActionConclusion.Continue); }