- Home /
This question was
closed Dec 05, 2013 at 02:00 AM by
clunk47 for the following reason:
The question is answered, right answer was accepted
GetButton Problem
Here's a part of code:
if (Input.GetButton ("Aiming")){
target.animation.CrossFade ("aiming");
walkSpeed = 0;}
if (Input.GetButton("Aiming")){
if (Input.GetButton("Action")){
target.animation.CrossFade("shoot",0.1);
}}
What I actually tend to achieve is make it work like so: if Aiming button pressed then aiming animation's played and only after that I can press button Action to perform shooting action(play shooting animation). But on the other hand if Action button pressed first and then I press Aiming button, I don't want shooting action happen and let character stay in idle pose just like no button was pressed. I guess I need somehow block Aiming Button Input when Action button is pressed. Any ideas how to achieve this? Thanks for your feedback :)
Comment
Best Answer
Answer by clunk47 · Sep 10, 2013 at 09:27 PM
Try using a boolean.
bool canShoot;
if(Input.GetButton("Aiming"))
canShoot = true;
else
canShoot = false;
if(canShoot)
{
if(Input.GetButton("Action"))
{
target.animation.CrossFade("shoot", 0.1f);
}
}
If you are using JS, bool canShoot would be
var canShoot : boolean;