Skip to content


How to Instantiate Particles System on Collision

public GameObject particlesPrefab; public Transform origin; void OnTriggerEnter(Collider collider){ if (collider.gameObject.CompareTag(“Tag”)) { GameObject particlesPrefabInstance = (GameObject)Instantiate(particlesPrefab, origin.TransformPoint(0, 0, 0), origin.rotation); } }

How to Activate or Deactivate a GameObject in Unity

To activate or deactivate a gameobject by scripting, use the SetActive function. public class ExampleClass : MonoBehaviour { void Start () { gameObject.SetActive(false); //GameObject is activated in hierarchy and will be deactivated when game starts. } }