In this video, we talk through our goals for this 2 part series, the basics of creating a trigger collider, rigid body, C# script, and event setup for a trigger input. In Unity 6.1, we go line by line through the C# script that will enable you to add simple triggered events in your projects.
Script -
using UnityEngine;
using UnityEngine.Events;
public class TriggerEvent : MonoBehaviour
{
public UnityEvent uEvent;
public GameObject TriggerObject;
public void OnTriggerEnter(Collider collider)
{
if (collider.gameObject == TriggerObject)
uEvent.Invoke();
}
}
Ещё видео!