29 lines
532 B
C++
29 lines
532 B
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "WalkAnimInstance.h"
|
|
#include "GameFramework/Pawn.h"
|
|
#include "GameFramework/PawnMovementComponent.h"
|
|
|
|
|
|
void UWalkAnimInstance::NativeInitializeAnimation()
|
|
{
|
|
if (Pawn == nullptr)
|
|
{
|
|
Pawn = TryGetPawnOwner();
|
|
}
|
|
|
|
if (IsValid(Pawn))
|
|
{
|
|
MovementComponent = Pawn->GetMovementComponent();
|
|
}
|
|
}
|
|
|
|
void UWalkAnimInstance::NativeUpdateAnimation(float DeltaSeconds)
|
|
{
|
|
if (Pawn && MovementComponent)
|
|
{
|
|
Speed = Pawn->GetVelocity().Size();
|
|
}
|
|
}
|