- Home /
Script for tank fire
I am making game in the spirit of Tank battle arena, and I need a script for my tank to fire( if you happen to know some ), or at least some hints for me to do it on my own. Thank you in advance for your involvement. :)
There is a guy on youtube who did a really good tutorial on essentially asteroids. It doesn't sound like it would be helpful but it really is. Link. It explains good methods for firing in w/e direction you want, making sounds, having the bullet remove life if it makes contact etc... really helpful.
Ye, this looks something like I wanted to do, but what about I implement some object of Ray type and make it to behave like a bullet?
Answer by valaxgames · Dec 01, 2012 at 05:19 PM
//Create a rigidbody prefab and put it here
var shell : Rigidbody;
//Make an empty gameobject and put it at the end of the barrell
//Then assign it in the editor as this variable
var muzzle : Transform;
function Update () {
if(Input.GetMouseButtonDown(0)){
Instantiate(shell, muzzle.position, muzzle.rotation);
//Makes the shell move
var forward = transform.TransformDirection(Vector3.forward);
instantiatedBullet.AddForce (forward * 1000);
}
}
Hope this helped you ;)
Your answer
Follow this Question
Related Questions
Save Position script. 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
I need help with a script(brauche hilfe mit einen Script) 0 Answers
How to make an object fallow you and disapear 2 Answers
A node in a childnode? 1 Answer