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

more ▼

asked May 25 '11 at 01:46 AM

Unit875 gravatar image

31 5 6 7

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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. :)

Blowing stuff up requires a few steps:


more ▼

answered May 25 '11 at 02:10 AM

NinjaSquirrel gravatar image

774 32 41 69

(comments are locked)
10|3000 characters needed characters left

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) {

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

more ▼

answered May 25 '11 at 02:10 AM

MeatbagWammo gravatar image

152 4 4 12

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: May 25 '11 at 01:46 AM

Seen: 1532 times

Last Updated: May 25 '11 at 02:12 AM