Import 2D Level
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class SimpleTrigger : MonoBehaviour
|
||||
{
|
||||
|
||||
public Rigidbody2D triggerBody;
|
||||
public UnityEvent onTriggerEnter;
|
||||
|
||||
|
||||
void OnTriggerEnter2D(Collider2D other){
|
||||
//do not trigger if there's no trigger target object
|
||||
if (triggerBody == null) return;
|
||||
|
||||
//only trigger if the triggerBody matches
|
||||
var hitRb = other.attachedRigidbody;
|
||||
if (hitRb == triggerBody){
|
||||
onTriggerEnter.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user