- Home /
reload help
hello guys i have a question of my shoot script: how can i place a reload in my script. this is my script
var shotsound:AudioClip;
var shellPrefab : GameObject;
var proyectilevelocity:int;
var ammo:int;
var fireRate = 1.0;
private var nextfire = 0.0;
function FixedUpdate () {
if(Input.GetButton("Fire1") && Time.time>nextfire && ammo>0)
ShotProyectile();
}
function ShotProyectile(){
if(Time.time > nextfire)
{
var Grenade:GameObject = Instantiate(shellPrefab,transform.position,transform.rotation);
Grenade.GetComponentInChildren(Rigidbody).velocity =transform.TransformDirection(Vector3(0,0,proyectilevelocity));
//Physics.IgnoreCollision(shellPrefab.GetComponentInChildren(BoxCollider).collider,transform.parent.collider);
ammo--;
if(shotsound)
audio.PlayOneShot(shotsound);
Destroy(Grenade,10);
nextfire = Time.time+fireRate;}
}
Comment
Your answer
Follow this Question
Related Questions
Shoot script help 1 Answer
Shoot Script Reload Help 1 Answer
Wrote a script for Shooting, reloading and to display the AMMO in a GUIText 1 Answer
No Reload Script Works 1 Answer
simple shooting script help 3 Answers