Example #1
0
    // Use this for initialization
    void Start()
    {
        //Finds the Cletus GameObject to later follow him once detected
        GameObject player = GameObject.FindWithTag("Cletus");

        onSpawn.Invoke(player.transform);
    }
Example #2
0
    private void Start()
    {
        //use the tag to find the player
        GameObject Player = GameObject.FindWithTag("Player");

        //call invoke for the onspawn custom event giving it the player transform
        onSpawn.Invoke(Player.transform);
    }
Example #3
0
    /*
     * Start
     * this method is provided by Monobehaviour that only runs ONCE when the Enemy is spawned
     * see link: https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html
     * we will use this to get the player in the scene and send our onSpawn event
     */
    private void Start()
    {
        /*
         * FIND THE PLAYER IN THE SCENE
         * we create a local GameObject variable for the player
         * we use GameObject.FindWithTag to find the player in the scene
         * NOTE: our player's GameObject in the scene needs to have a tag of "Player"
         * see link: https://docs.unity3d.com/ScriptReference/GameObject.FindWithTag.html
         * see link: https://docs.unity3d.com/Manual/Tags.html
         */
        GameObject player = GameObject.FindWithTag("Player");

        /*
         * SEND THE onSpawn EVENT USING Invoke
         * Here we send the onSpawn event using the Invoke method of the event
         * because our onSpawn event is a custom one, it needs to send a transform with the event
         * We use the player GameObject we just found in the scene (see code above)
         * to get the players transform component, we use player.transform
         * see link: https://docs.unity3d.com/ScriptReference/Events.UnityEvent.Invoke.html
         * see link: https://docs.unity3d.com/ScriptReference/Events.UnityEvent.html
         */
        onSpawn.Invoke(player.transform);
    }
 // public methods
 // create event to publish that enemy spawned
 public void PublishOnEnemySpawnedEvent()
 {
     //
     EnemySpawnedEvent?.Invoke();
 }
Example #5
0
 public void PublishEnemySpawnedEvent()
 {
     EnemySpawnedEvent?.Invoke();
 }
Example #6
0
 public void RpcNotifyEnemySpawn(GameObject enemy)
 {
     enemySpawnedEvent.Invoke(enemy);
     //player.GetPlayerPawn().InitializeStats(player.GetComponent<PlayerStats>().GetTotalStatStruct());
 }
    private void Start()
    {
        GameObject player = GameObject.FindWithTag("Player");

        onSpawn.Invoke(player.transform);
    }
Example #8
0
        // == Private Messages ==


        // == Event Methods ==
        protected void PublishEnemySpawnedEvent()
        {
            EnemySpawnedEvent?.Invoke(); // Publishing the event
        }
Example #9
0
 public void RpcNotifyBossSpawn(GameObject boss)
 {
     bossSpawnedEvent.Invoke(boss);
 }
Example #10
0
 //public methods
 public void PublishEnemySpawnedEvent()
 {
     //if event is not null, someone is listening, so tell them
     EnemySpawnedEvent?.Invoke();
 }
Example #11
0
 private void PublishOnEnemySpawnedEvent()
 {
     // Signal that an Enemy has spawned
     EnemySpawnedEvent?.Invoke();
 }