flame moving with the object

A player shoots on a vehicle. If it shoots correctly, a flame starts to burning on the car after hitting. The flame should go with the vehicle if the vehicle is moving. But the flame does not moving with the vehicle, how to solve this issue? I used OnCollisionEnter (see below).

Thanks in advance.
Dave

var SmallFlame : GameObject;

function OnCollisionEnter (collision : Collision) {
var contact : ContactPoint = collision.contacts[0];
var rotation = Quaternion.FromToRotation(Vector3.up, contact.normal);
var CollidedObj : String = collision.transform.name;

if (CollidedObj == “Vehicle1”) {
Instantiate (SmallFlame, contact.point, rotation);
}

}

You need to add a parent to the instantiated flame… something like this:

theFlame = Instantiate (SmallFlame, contact.point, rotation); 

theFlame.transform.parent = gameObject;

:smile:

I used:
theFlame.transform.parent = collision.transform
In my case, gameObject is collision.transform

It works!
Thank you very much!

Dave