/// <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);
        }
Exemplo n.º 2
0
        private void Awake()
        {
            m_Movement = GetComponent <ServerCharacterMovement>();

            NetState       = GetComponent <NetworkCharacterState>();
            m_ActionPlayer = new ActionPlayer(this);
            if (IsNpc)
            {
                m_AIBrain = new AIBrain(this, m_ActionPlayer);
            }
        }
        public override bool Start()
        {
            m_Movement = m_Parent.GetComponent <ServerCharacterMovement>();

            if (m_Data.TargetIds != null && m_Data.TargetIds.Length > 0)
            {
                NetworkObject initialTarget = NetworkSpawnManager.SpawnedObjects[m_Data.TargetIds[0]];
                if (initialTarget)
                {
                    // face our target, if we had one
                    m_Parent.transform.LookAt(initialTarget.transform.position);
                }
            }

            m_Parent.NetState.RecvDoActionClientRPC(Data);
            return(true);
        }
Exemplo n.º 4
0
        public override bool Start()
        {
            m_PreviousStage = ActionStage.Windup;
            m_Movement      = m_Parent.GetComponent <ServerCharacterMovement>();

            if (m_Data.TargetIds != null && m_Data.TargetIds.Length > 0)
            {
                NetworkObject initialTarget = NetworkSpawnManager.SpawnedObjects[m_Data.TargetIds[0]];
                if (initialTarget)
                {
                    // snap to face our target! This is the direction we'll attack in
                    m_Parent.transform.LookAt(initialTarget.transform.position);
                }
            }

            m_Parent.NetState.RecvDoActionClientRPC(Data);
            return(true);
        }
Exemplo n.º 5
0
        public override bool Start()
        {
            //we must always clear the existing target, even if we don't run. This is how targets get cleared--running a TargetAction
            //with no target selected.
            m_Parent.NetState.TargetId.Value = 0;

            //there can only be one TargetAction at a time!
            m_Parent.RunningActions.CancelRunningActionsByLogic(ActionLogic.Target, true, this);

            if (Data.TargetIds == null || Data.TargetIds.Length == 0)
            {
                return(false);
            }

            m_Movement = m_Parent.GetComponent <ServerCharacterMovement>();

            m_Parent.NetState.TargetId.Value = TargetId;

            FaceTarget(TargetId);

            return(true);
        }