- Home /
This question was
closed Jul 08, 2021 at 03:11 PM by
Gurdan.
Question by
Gurdan · Jul 08, 2021 at 03:00 PM ·
c#if-statements
Tips on how to handle multiple if statemens
Hi, i'm a beginner, i want to know if there are better way to handle this kind of situations, if in the future the game will be bigger, this kind of workflow can cause some performance issues? Thanks in advance.
if (scriptMovement.IsGrounded() && scriptMovement.horizontal == 0 && !scriptMovement.isShooting)
{
ChangeAnimationState(Player_Idle);
}
else if (scriptMovement.IsGrounded() && scriptMovement.horizontal < 0 || scriptMovement.IsGrounded() && scriptMovement.horizontal > 0)
{
ChangeAnimationState(Player_Run);
}
else if (!scriptMovement.IsGrounded() && rb.velocity.y < 0 && !scriptMovement.isWallSliding)
{
ChangeAnimationState(Player_FallOff);
}
else if (scriptMovement.isJumping)
{
ChangeAnimationState(Player_Jump);
}
else if (scriptMovement.isWallSliding && scriptMovement.WallSlide)
{
ChangeAnimationState(Player_WallSliding);
}
else if (scriptMovement.isShooting == true)
{
ChangeAnimationState(Player_Shooting);
Debug.Log(1);
}
Comment
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
C# the position of the object 1 Answer
If gameobject moves do this 1 Answer
Value not changing back to where its supposed to... 0 Answers