|
i was watching the fps techzone tutorial and noticed the rockets dont do damage does anyone know how to add it? please help! rocket script:
if it helps here is the machine gun script with damage from same download:
(comments are locked)
|
|
So what Meater6 was trying to say was to add a hit points system. I commented it and simplified it to make it less confusing.
Attach this to your rocket, by the way. Cheers! your worked best but my enemy has a rocket to and i want the rocket to hurt me too what could i do
Apr 25 '11 at 03:32 AM
jacques 1
You attatch this script to the player, and tag anything that could hurt the player with "Enemy."
Apr 25 '11 at 03:37 AM
Flafla2 1
can u hav multiple tags to one object?
Apr 25 '11 at 03:41 AM
jacques 1
At the moment, no. However, you can also use gameobject.name, and just name the gameObject something.
Apr 25 '11 at 04:23 PM
Flafla2 1
nothing happens:(
Apr 25 '11 at 07:45 PM
jacques 1
(comments are locked)
|
|
heres what i would do, this is a health script add this to the object you want to take damage:
and add a tag Rocket to your rocket prefab.
(comments are locked)
|
|
To do damage, you must have something that takes the damage. Make a enemy status script, if don't have one already, for if you do, put it in your question. Ok, you need to check to see if the rocket hit a valid target. Add a rocket damage script to the rocket you are instantiating. Using
Add a "Enemy" tag to the thing your shooting at and check to see if the rocket hit something with that tag. If it has, send a message using
in the rocket damage script. This will run the SubtractHealth function with parameters "damage" in the enemy status script. For the complete script, comment on this saying so. EDIT: Actually, an easier way is to just have a hitPoints variable, and subtract form that. "RocketStatus" (The one that goes on the rocket itself)
"EnemyStatus" (The one that controls the hit points)
These scripts are untested, but I am positive they will work fine. Hope this gives you a better idea of how this works. wait so what would the rockets final script look like, i know basicly nothing about scripting
Apr 24 '11 at 08:03 PM
jacques 1
complete script please
Apr 25 '11 at 12:48 AM
jacques 1
(comments are locked)
|

idk what happened why its choppy like that
Hey man, just had to code-ify your code. Next time when posing code, just highlight it, and push the 10101 button up top =). Thanks!