OK, so I have a vehicle that I can drive around a terrain, but I want it to be able to shoot bullets at another object with a damage script and make those bullets inflict dameage.how would I do this?
to fire projectiles, like a rocket, use Instantiate (this page has a simple missile script):
http://unity3d.com/support/documentation/ScriptReference/Object.Instantiate.html
for something like a machine gun though, you would use Raycast. Trickier to set up in my opinion, so let’s stick to the rocket for now. Use the projectile script from the above link,
and attach that to your vehicle. You will need to create a projectile, it could be as simple as a box with a rigidbody attached. Turn your projectile into a prefab. Then select your vehicle, and in the inspector panel you can see the script you attached. Drag the prefab object from your project panel to the “projectile” slot in the inspector (you may need to click the little arrow by the script name to expand it). Then push play, see what you did wrong, try to fix it… Once you get that working, you can move on to damage, which would probably be a trigger:
http://unity3d.com/support/documentation/ScriptReference/Collider.OnTriggerEnter.html
the link above shows the function, just replace “Destroy(other.gameObject);” with something else, like:
var healthScript = other.GetComponent(“YourScriptNameHere”);
healthScript.TakeDamage();
there would need to be such a script attached to the other object. It could all be part of the same script, and each player would have one attached, or it could be a separate script dedicated to health, or whatever… Keep in mind for the trigger to work, both objects involved in the collision need a collider attached, and one needs a rigidbody also (which in this case should already be)
Search the tutorials, search the forums, you’ll find many examples of all this, good luck