In this lesson, you will learn how to bypass the standard character movement systems to create custom locomotion by manually updating a Pawn’s transform coordinates every frame.
Why Manual Movement?
While Unreal Engine provides robust movement components, sometimes you need specialized behavior—like a hovering drone, a sliding physics-based ball, or a simplified arcade craft—that doesn't fit standard walking physics. When we extend the Pawn class, we gain the freedom to define our own movement rules. Instead of relying on a "Character Movement Component," we use the Tick function to recalculate the Pawn’s position based on a velocity vector we define ourselves.
Implementing Tick-Based Movement
The core idea is to calculate a displacement vector (Velocity × DeltaTime) and add it to the Pawn's current location. We override the Tick function in our C++ Pawn class to perform this calculation continuously while the game is running.
Here is how you might structure the logic:
void AMyCustomPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// Calculate the frame-by-frame offset
// Velocity is a custom FVector variable we define
FVector Displacement = Velocity * DeltaTime;
// Directly update the actor's transform
FVector NewLocation = GetActorLocation() + Displacement;
SetActorLocation(NewLocation);
}
Understanding the Logic
By multiplying your velocity by DeltaTime, you ensure your Pawn moves at a consistent speed regardless of the player's frame rate. If your game runs at 60 FPS or 144 FPS, the DeltaTime gets smaller as the frame rate increases, keeping the movement distance per second perfectly smooth.
Because you are manipulating the transform directly via SetActorLocation, you bypass the traditional friction, gravity, and floor detection used by the standard Character class. This gives you total creative control: if you want your Pawn to zip through walls, orbit objects, or move in erratic patterns, you simply change the math inside your Tick function. You are no longer a passenger of the physics engine; you are the driver of the Pawn’s coordinate system.
Key Takeaway: By overriding the Tick function and manually updating the Pawn’s location using a velocity vector and DeltaTime, you can implement unique, custom movement logic that operates independently of standard Unreal Engine physics systems.