all repos — RPG @ 600326a2970450d00cdb49c7829765d373c55c3f

Fully functional 3D turn based role playing game coded in C# and base Unity.

Assets/Scripts/Overworld/IsEnemyTrigger.cs (view raw)

 1using UnityEngine;
 2using UnityEngine.SceneManagement;
 3
 4[RequireComponent(typeof(Rigidbody))]
 5[RequireComponent(typeof(CapsuleCollider))]
 6public class IsEnemyTrigger : MonoBehaviour
 7{
 8    private GameMaster gm;
 9    public string EnemyType;
10
11    private void Start()
12    {
13        gm = GameMaster.Instance;
14    }
15
16    void OnTriggerEnter(Collider other)
17    {
18        if (other.gameObject.name == "Player")
19        {
20            gm.EnterBattle(transform.parent.name, EnemyType);
21        }
22            
23    }
24}