unreal/WalkAnimInstance.cpp

29 lines
532 B
C++
Raw Normal View History

2022-01-11 11:07:17 +01:00
// 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();
}
}