I am making a racing game and I want to have the barriers I set up look damaged when they are hit. I have the model set up for it but scripting it in to switch the models is what I am having a problem doing.
I started a script but didn’t get very far. I am confused on how to proceed from here.
var brokBarrier: GameObject ;
function OnCollisionEnter(other : Collider)
{
}
That is all I have so far could someone please help me?
To have the damaged look, you can place a different ‘broken’ model in its place. One more way you can get a damage effect is to change the texture of the barrier to a more worn and torn texture when the car collides, however I think you are interested in the first one.
have this in the OnCollisionEnter function
Instantiate(brokBarrier, transform.position, transform.rotation); //place a broken barrier
Destroy(gameObject); //destroy the old barrier