Trying to add pre-jump logic and animation

This commit is contained in:
Kevin Poretti 2022-01-29 22:24:26 -05:00
parent 2eeac7443e
commit c73e8b1c5a
6 changed files with 40 additions and 10 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -71,20 +71,28 @@ UPaperFlipbook* AKOFBaseCharacter::GetAnimation(FName Key)
void AKOFBaseCharacter::UpdateAnimation() void AKOFBaseCharacter::UpdateAnimation()
{ {
// need to get the animation based on what state we're in...
// rendering // rendering
if(!bIsInAir) if(!bIsInAir)
{ {
if(Direction > 0) if(bWantsToJump)
{ {
SetAnimationFlipbook("WALK_FWD"); SetAnimationFlipbook("PRE_JUMP");
}
else if (Direction < 0)
{
SetAnimationFlipbook("WALK_BACK");
} }
else else
{ {
SetAnimationFlipbook("IDLE"); if(Direction > 0)
{
SetAnimationFlipbook("WALK_FWD");
}
else if (Direction < 0)
{
SetAnimationFlipbook("WALK_BACK");
}
else
{
SetAnimationFlipbook("IDLE");
}
} }
} }
else else
@ -124,7 +132,7 @@ void AKOFBaseCharacter::ProcessInputs(EVirtualGamePadButton Button)
switch(Button) switch(Button)
{ {
case EVirtualGamePadButton::VGP_Up: case EVirtualGamePadButton::VGP_Up:
Jump(); bWantsToJump = true;
break; break;
} }
} }
@ -202,6 +210,16 @@ void AKOFBaseCharacter::Tick(float DeltaTime)
{ {
Super::Tick(DeltaTime); Super::Tick(DeltaTime);
if(!bIsInAir && bWantsToJump)
{
TicksSinceJumpRequested++;
if(TicksSinceJumpRequested >= 4)
{
Jump();
TicksSinceJumpRequested = 0;
bWantsToJump = false;
}
}
// character logic // character logic
UpdateMovement(FFixed(DeltaTime)); UpdateMovement(FFixed(DeltaTime));

View File

@ -98,6 +98,9 @@ protected:
void UpdateMovement(FFixed DeltaTime); void UpdateMovement(FFixed DeltaTime);
bool bIsInAir; bool bIsInAir;
bool bWantsToJump;
int TicksSinceJumpRequested;
void Jump(); void Jump();