How to make a script that manages what animations to play on the gun based on what button is pressed.
1 Answer
1So i decided to answer it my self:
var shoot : Animation;
var sprint : Animation;
var idle : Animation;
var aim : Animation;
var aimshoot : Animation;
function Update(){
if(Input.GetButtonDown("Sprint"))
{
animation.Play(sprint);
}
else if(Input.GetButtonUp("Sprint"))
{
animation.Play(idle);
}
if(Input.GetButtonDown("Shoot"))
{
animation.Play(shoot);
if(Input.GetButtonDown("Aim"))
{
animation.Play(aimshoot);
}
}
else if(Input.GetButtonUp("Shoot"))
{
animation.Play(idle);
}
if(Input.GetButtonDown("Aim"))
{
animation.Play(aim);
}
else if(Input.GetButtonUp("Aim"))
{
animation.Play(idle);
}
function Start(){
animation.Play(idle);
}
if input this button do this animation if input this button{ this animation } so on but have it send to the same function you use for firing, unless you also shoot different bullets, then just do different things, use complete new input detection for each action edit--managing, when pushing a specific button have it send the name to a function that says if this name is this do this or if this name is that do this very vague answer lol but basic idea is there
– joeyaaaaaa basic is idea is what i need i dont need a script that can make my gun do complex stuff, i just need one if statement to get me started
– DryTearif(input.GetButton("attack")|| input.GetButton("attack2")||input.GetButton("attack3") && sometTime < Time.time ) { if(input.GetButton("attack"){ //do this //someTime = Time.time + 2; if(input.GetButton("attack2"){ //do this //someTime = Time.time + 2; } if(input.GetButton("attack3"){ //do this //someTime = Time.time + 2; } } } i have a feeling this isnt what you meanbut its all i can come up with lol
– joeyaaaaajust what i need - i just gotta change the comments to animation.Play(variable);
– DryTearyes exactly hehe but lookign at this is slightly redundant, idont think you have to check each button with the || symbols, just remove that and its bracket, and check fo rany and base it off that as you would normally
– joeyaaaaa