Make firing range targets blow up

hey,
I need some help. I have a firing range for my fps and i need to know how to get the targets to blow up when you shoot them. it would also help if they can move too. Thanks

No one is going to give you an entire script just for you. Try to do as much of it as you can yourself, and if you run into specific problems we will be more than happy to help. :slight_smile:

Blowing stuff up requires a few steps:

Movement:

Hi Unit875,

The first thing you need to do is add a box or mesh collider to your targets. Then you need to make the collider a trigger. There is a check box for each collider to change it into a trigger.

Then you have to write a script that will check for the bullets to collide/intersect the collider.

It will be something like this:

    //Script for collider:
    var gotHit = false;
    
    function OnTriggerEnter(hit : Collider) {
		if(hit.gameObject.tag == "bullet") {
			gotHit = true;
		}

For the target itself, you will have to write a funtion that checks if gotHit is true.

It will look something like this:

    //Script for target:
    function Update() {
        if(gotHit) {
            destroy(gameObject);
        }
    }

I hope this helps! You can add onto, or rewrite this code. I was just giving examples on how to pull it off.

Have a grate time with Unity3d!

Sincerely,
Meatbagwammo