-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnpc.cs
More file actions
31 lines (26 loc) · 733 Bytes
/
npc.cs
File metadata and controls
31 lines (26 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Collections;
using UnityEngine;
using System.Collections.Generic;
public class npc : MonoBehaviour
{
private Collider2D z_Collider;
[SerializeField]
private ContactFilter2D z_Filter;
private List<Collider2D> z_CollidedObjects = new List<Collider2D>(1);
protected virtual void Start()
{
z_Collider = GetComponent<Collider2D>();
}
protected virtual void Update()
{
z_Collider.Overlap(z_Filter, z_CollidedObjects);
foreach(var o in z_CollidedObjects)
{
OnCollided(o.gameObject);
}
}
protected virtual void OnCollided(GameObject collidedObject)
{
Debug.Log("Collided with " + collidedObject.name);
}
}