35 lines
941 B
C++
35 lines
941 B
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "ShooterAnimInstance.h"
|
|
|
|
#include "ShooterCharacter.h"
|
|
#include "GameFramework/CharacterMovementComponent.h"
|
|
|
|
void UShooterAnimInstance::UpdateAnimationProperties(float DeltaTime)
|
|
{
|
|
if (ShooterCharacter)
|
|
ShooterCharacter = Cast<AShooterCharacter>(TryGetPawnOwner());
|
|
|
|
if (ShooterCharacter)
|
|
{
|
|
// Get the speed of the character from velocity
|
|
FVector Velocity{ ShooterCharacter->GetVelocity() };
|
|
Velocity.Z = 0;
|
|
Speed = Velocity.Size();
|
|
|
|
// Is the character in the air
|
|
bIsInAir = ShooterCharacter->GetCharacterMovement()->IsFalling();
|
|
|
|
// Is the character accelerating
|
|
bIsAccelerating = ShooterCharacter->GetCharacterMovement()->GetCurrentAcceleration().Size() > 0;
|
|
}
|
|
}
|
|
|
|
void UShooterAnimInstance::NativeInitializeAnimation()
|
|
{
|
|
Super::NativeInitializeAnimation();
|
|
|
|
ShooterCharacter = Cast<AShooterCharacter>(TryGetPawnOwner());
|
|
}
|