I’m currently building a 3D platformer and would like to implement a function to disregard any input while the current animation is played, as whilst i’m doing things such as climb or jump I can keep pressing jump to repeat the state over and over; and in a way double jump - this I DONT want.
void Jumping()
{
if ((!animation.isPlaying TP_Controller.CharacterController.isGrounded) ||
TP_Controller.CharacterController.isGrounded)
{
if (LastState == CharacterState.Running)
animation.CrossFade("RunLand");
else
animation.CrossFade("JumpLand");
State = CharacterState.Landing;
}
else if (!animation.IsPlaying("Jump"))
{
State = CharacterState.Falling;
animation.CrossFade("Falling");
}
else
{
State = CharacterState.Jumping;
// if (transform.position.y > TP_Motor.Instance.StartFallHeight)
// TP_Motor.Instance.StartFallHeight = transform.position.y;
}
}
all depends on what he wants to do… your line of code works in 95% of games out there, but he may want the character to be able to start the jump animation regardless of the animation state so long as he is grounded… (perhaps he has a really long jump animation or he’s jumping while moving up a really steep hill?)
meh; either one’s pretty extreme… the more I think about it the more I like yours better
In regards to this code; I want to disable any input when particular animations are played; for example i have a climbing animation which lasts 3 seconds - i can move left right up down, and even jump whilst this is taking place; I want to remove any allowance of this until the animation has finished.
Sorry if i wasn’t clear enough but it’s not just jump i want this to apply to.
Can’t you just put something like this at the top of where you’re processing your input? i.e…
void ProcessInput() {
if (animationIsPlaying) {
return;
}
// .. your input processing code
}
So when you start an animation, you set the value to true and when it stops playing you set the value to false. You need a routine that checks if the animation is playing.