ontrigger unity code example
Example 1: unity on trigger enter
private void OnTriggerEnter(Collider other)
{
}
Example 2: setactive unity
gameObject.SetActive(true);
gameObject.SetActive(false);
Example 3: setparent unity
using UnityEngine;public class ExampleClass : MonoBehaviour
{
public GameObject child; public Transform parent;
public void Example(Transform newParent)
{
child.transform.SetParent(newParent);
child.transform.SetParent(newParent, false);
child.transform.SetParent(null);
}
}
Example 4: unity gameobject.find
GameObject obj = GameObject.Find("/Parent/Child/ChildOfChild");
Example 5: ontriggerenter
private void OnTriggerEnter(Collider other)