PluginsUDCoreFeaturesAsync Tasks
Async Tasks
Simplified asynchronous operations with Blueprint latent action support
UDCore provides async task classes that simplify common asynchronous operations in Unreal Engine. These tasks work seamlessly with Blueprints as latent actions and provide clean callback patterns in C++.
Available Async Tasks
How Async Tasks Work
In Blueprints
Async tasks appear as latent nodes (nodes with a clock icon) in Blueprints. They:
- Execute over multiple frames
- Provide output execution pins for different outcomes (success/failure)
- Can be cancelled if needed
In C++
Async tasks use delegate callbacks:
#include "AI/UDAT_MoveToLocation.h"
// Create and start the task
UUDAT_MoveToLocation* Task = UUDAT_MoveToLocation::MoveToLocation(
GetWorld(),
Controller,
Destination,
AcceptanceRadius,
bDebugLineTrace
);
// Bind completion callback
if (Task)
{
Task->Completed.AddDynamic(this, &ThisClass::OnMoveCompleted);
}
// Callback function
void AMyClass::OnMoveCompleted(bool bSuccess)
{
if (bSuccess)
{
// Movement succeeded
}
else
{
// Movement failed or was cancelled
}
}Common Patterns
Chaining Async Operations
void AMyCharacter::StartPatrol()
{
MoveToNextPatrolPoint();
}
void AMyCharacter::MoveToNextPatrolPoint()
{
FVector NextPoint = GetNextPatrolPoint();
UUDAT_MoveToLocation* Task = UUDAT_MoveToLocation::MoveToLocation(
GetWorld(),
GetController(),
NextPoint,
50.0f,
false
);
if (Task)
{
Task->Completed.AddDynamic(this, &ThisClass::OnPatrolPointReached);
}
}
void AMyCharacter::OnPatrolPointReached(bool bSuccess)
{
if (bSuccess)
{
// Wait, then move to next point
GetWorldTimerManager().SetTimer(
PatrolTimerHandle,
this,
&ThisClass::MoveToNextPatrolPoint,
2.0f,
false
);
}
}More async tasks may be added in future versions. Check the Changelog for updates.