- Home /
Unity 3rd person shoot script
HEY UNITY PEOPLE DO ANY OF U NOW A SCRIPT FOR 3RD PERSON TO MAKE HIM SHOOT A FIRE BALL OR BULLET OUT OF HIM?? I MEAN LIKE TORNADOTWINS SCRIPT WHERE IT SHOOTS OUT OF THEIR PLAYER TORNADOTWINS SCRIPT WONT WORK ON THE NEW UNITY 3.5 SO IF ANYONE NOW TELL ME PLEASE
THANKZ FROM CaM
Answer by fireomega · Feb 22, 2012 at 08:28 PM
Assuming I think you just want a simple shooting script when you click then you just do.
var projectile : Rigidbody;
var speed = 50;
var fireRate = 0.11;
private var lastShot = -10.0;
function Update () {
if(Input.GetButtonDown("Fire1")){
if(Time.time > fireRate+lastShot){
clone = Instantiate(projectile, transform.position, transform.rotation);
projectile.tag = "Bullet";
clone.velocity = transform.TransformDirection( Vector3 (0, 0, speed));
lastShot = Time.time;
}
Destroy(clone.gameObject, 3);
}
}
Then basically make a empty gameObject and put it at the end of the barrel of the gun and attach this script to it.
If this answered your question please click on the tick
Well the fire ball appears with this script but this is what happens
the fireball appears for like one second and dissapears after anyone else have an answer or fire omega can u help
Answer by 321everybodycares · Feb 23, 2012 at 03:51 AM
Well the fire ball appears with this script but this is what happens
the fireball appears for like one second and dissapears after anyone else have an answer or fire omega can u help
Answer by fireomega · Feb 24, 2012 at 07:48 PM
assuming you want it to be automatic just change the "GetButtonDown" to just "GetButton" or you could just play around with the fire rate
Answer by fireomega · Feb 24, 2012 at 07:53 PM
Or if you want to stop them disappearing then just get rid of the Destroy line at the bottom
Answer by $$anonymous$$ · Jul 15, 2014 at 07:30 AM
What coding script is that? (JS, C#, Boo?)
Whoa, sorry, I was new at the time, didn't know there was a comment button to the side...