18 lines
574 B
C#
18 lines
574 B
C#
|
using UnityEngine;
|
||
|
|
||
|
namespace Interactable.Interactor
|
||
|
{
|
||
|
[RequireComponent(typeof(Collider2D), typeof(Rigidbody2D))]
|
||
|
public class ColliderTriggerInteractor : MonoBehaviour
|
||
|
{
|
||
|
protected IInteractable interactable = null;
|
||
|
protected virtual void Start()
|
||
|
{
|
||
|
interactable = GetComponent<IInteractable>();
|
||
|
GetComponent<Collider2D>().isTrigger = true;
|
||
|
GetComponent<Rigidbody2D>().isKinematic = true;
|
||
|
}
|
||
|
protected virtual void OnTriggerEnter2D(Collider2D other) => interactable.Interact();
|
||
|
}
|
||
|
}
|