question about a script

how can i change this script to not destroy object but to immoblize it and trigger a smoke or fire effect

var Explosion : Transform;

function OnCollisionEnter(collision : Collision){

if (collision.gameObject.tag == “Finish”)

Instantiate(Explosion, transform.position, transform.rotation);


thank you


Um… well you’re asking for a lot of work. The easy answer is that you take out the Destroy() and Instantiate(Explosion) functions and replace them with your own functions to immobilize and start a smoke effect.


function OnCollisionEnter(collision : Collision){
    if (collision.gameObject.tag == "Finish") {
        Instantiate(Smoke, transform.position, transform.rotation); 
function Immobilize( aGameObject : GameObject) {
    //Immobilization code goes here

(And you’d need a prefab called Smoke.)

I can’t answer what should be in the immobilize function because I don’t know how you do movement or input in your game.

For how to create a Smoke prefab, you should do a search for smoke particle effects in unity. It’s likely someone has a good starting point.