- Home /
Ammo collection problem/re enabiling a script
plese help me i have been trying to figure this iut for a bit now and i have come up empty handed i am trying to do a simple ammo collection script that works by re enabiling a script
(this is the one that allows me to shoot tight now it is disabled by the second script)
**var myBulletPrefab : Rigidbody; var ShootForce : int = 100; var ShootClip : AudioClip; var gun : GameObject; static var ammo : int = 100; function Update () {
if((Input.GetButtonDown("Fire1")) && ammo > 0 ) {
var Bullet : Rigidbody = Instantiate(myBulletPrefab, transform.position, transform.rotation);
Bullet.velocity = transform.TransformDirection(Vector3 (0,0,ShootForce));
audio.PlayOneShot(ShootClip);
gun.animation.Play ("shoot");
gun.animation.PlayQueued ("idle");
ammo--;
}
}**
(this is the script thae diables the previous script)
**var script : BulletShooter;
function Start() {
script = GetComponent(BulletShooter);
script.enabled = false;
}**
but i have no idea how to re enable the script all of the scripts are on my gu
This is never going to work. Everytime you enable the script, it runs the Start function, which disables it again. You need to rethink your process. Ins$$anonymous$$d of diabling, use a boolean which you toggle between true/false. Then if the boolean is true, doo stuff. Otherwise it acts just like it is disabled.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
unlocking weapon (fps) 1 Answer
Terrain with lots of objects 1 Answer
Please help me with this shooting script. 0 Answers
Modifying the FPS Walker script 1 Answer