How to Spawn different prefabs when colliding with different layers

nathanj

Active member
Hello,

Working on a cannon for a ship and wondering how you would suggest spawning different explosion effects based on which object the cannon collides with. Basically, there are two, a physical object (ship) with fire effects and water with a splash effect.

Was thinking i could add a collider to the spawned explosion game object and do a quick check on awake and enable one of two children.

But, wondering if there is a way to do this internally that you would recomend?

Using Projectile.


Thanks,
Nathan
 
For this I think that you could subclass the Projectile component and call it Cannonball, and then override the OnCollision method. This method has the RaycastHit which you can then use to spawn a different explosion.
 
Back
Top