I'm very sorry if this has been asked before, but I can't seem to figure this out.
Basically I want an explosion to spawn at the location of where an object is destroyed. I know this is a rather simple thing to do, but the script I've got for collisions is applied to the player.
I was wondering how I would write an IF statment in the script that is applied to the player to make an explosion spawn at the location of the destroyed objects.
From the documents:
"In contrast to OnTriggerEnter, OnCollisionEnter is passed the Collision class and not a Collider."
Taking this further, you can access collision information such as the gameObject or collider that you hit. Once you have the gameObject, you can get the position/transform, spawn an explosion, do other stuff...
function OnTriggerEnter(collisionInfo : Collision)
{
if (collisionInfo.gameObject.tag == "ExplodingGameObject"){
//explode
//use collisionInfo.transform.position to grab the location you need)
}
}