- Home /
This question was
closed Jun 13, 2018 at 02:48 AM by
GameDevH2O.
Question by
GameDevH2O · Jun 09, 2018 at 05:33 AM ·
c#android2d
How to apply explosion prefab to an object upon collision
Hello I turned a explosion sprite sheet into a prefab & having a hard time applying it to an object upon collision. Any help?
Comment
Answer by SohailBukhari · Jun 09, 2018 at 05:55 AM
Instantiate the prefab OnCollisionEnter
with the objects.
void OnCollisionEnter(Collision c)
{
Instantiate(prefab, c.gameObject.transform.position, someRotation);
}
For further details of Instantiate read this documentation https://docs.unity3d.com/Manual/InstantiatingPrefabs.html