Create Entities

Create entities in Unity.

Code Snippets

Here are the code snippets from this lesson

PlayerSpawn.cs


using UnityEngine;
public class PlayerSpawn : MonoBehaviour
{
    [SerializeField] GameObject player;

    void Start()
    {
        Debug.Log("Instantiate player");
        Instantiate(player, transform.position, Quaternion.identity);
    }
}

Exit.cs

using UnityEngine;
public class Exit : MonoBehaviour
{
    void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log("You finished the level!");
    }
}