Hey guys, just wondering if I could get a hand with this snippit of player control code. The farting animation gets cut off by my else statement that jumps to and idling animation. I want the fart animation to override all other animation on the monster. My brain is stuck in the mud on this one.
function PlayerMovement ()
{
var gAniObject = GameObject.Find("GuyAnimation"); // Find and define the animation mesh
if (Input.GetKey("right")) // Move Right
{
transform.position.x += playerMoveSpeed;
gAniObject.animation.Play("GuyWalk");
WalkingDirection(true);
}
else if(Input.GetKey("left")) // Move Left
{
transform.position.x -= playerMoveSpeed;
gAniObject.animation.Play("GuyWalk");
WalkingDirection(false); // flip model
}
else if (Input.GetKeyUp("space") Time.time > nextFart GuiControls.charge >= 1) //Fart
{
nextFart = Time.time + fartRate; // Fart timer spinning up
Instantiate (fartPrefab, transform.position, Quaternion.identity); // Instantiate fart Object
audio.PlayOneShot (fartSoundRegular); // Play fart sound
GuiControls.charge--; // Minus charges
gAniObject.animation.Play("GuyFart"); // Fart animation play
}
else
{
gAniObject.animation.Play("GuyIdle");
}
}