What script would you use to: run into a crate, destroy the crate when you run into it, not let you shoot unless you have more than zero ammo and add ammo to your inventory.
1 Answer
1The crate part I think I understand how to solve. Try this:
//OnCollisionEnter detects if something has touched the object this is on
//OnTriggerEnter can be used for trigger colliders
function OnCollisionEnter (object : Collision) {
//the crate needs the Crate tag
if(object.tag == "Crate"){
//destroy the crate
}
}
The ammo part is just simple math, so I kind of don't see the problem. It should look something like this:
if(fires){
if(ammo > 0){
ammo--;
}
else{
print("NO AMMO");
}
}
And please, look at the FAQ guidelines for better question asking, it will get you better answers.
um... 1) The title has nothing to do with the question 2) A useful tag to include would be 'collision-detection'
– anon20886517