|
I have a script on my gun which triggers animations on button press and another script which fires rays and reloads my gun ect. But how would I alter this so that if there are no bullets left I cannot play the shoot animation until there are, can anyone help me? animations script animation.wrapMode = WrapMode.Loop; animation["idle"].speed = 0.2; animation["walk"].speed = 1; animation["reload"].speed = 2.5; animation["shoot"].speed = 2; animation["shoot"].wrapMode = WrapMode.Once; animation["reload"].wrapMode = WrapMode.Once; animation["shoot"].layer = 1; animation["reload"].layer = 2; animation.Stop(); } function Update (){ if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1) animation.CrossFade("walk"); else animation.CrossFade("idle"); if(Input.GetButtonDown("Fire1")){ animation.Stop(); animation.Play("shoot"); } if(Input.GetButtonDown("r")){ animation.Stop(); animation.CrossFade("reload"); } } raycast, reload script var reloadTime = 1; function Update (){ if(Input.GetButtonDown("Fire1")){ if(Input.GetKeyDown("r")){ } function Reload (){ yield WaitForSeconds(reloadTime); amountOfShots = 8; } var shootSound : AudioClip; var bloodPrefab : Transform; var sparksPrefab : Transform; var hit : RaycastHit; var range = 500; function Shoot (){ if(Physics.Raycast(transform.position, transform.forward, hit, range)){ } }
(comments are locked)
|
|
Well, it looks like you have two scripts that aren't talking to each other. Edit:I suppose if you want to get dirty with it and make a quick change, you could also just add a bullet counter to your animation script. Thankyou for your help, sorry about the code I couldn't get it to format correctly.
Dec 14 '11 at 05:27 PM
Dreave
(comments are locked)
|

Please edit your post so that the whole of your code is in the code brackets, or nobody will read your code, and therefore, nobody will answer.
http://sscce.org. read it.