I‘m using un4 4.26(also have 4.24 and 4.22) on windows.
Now I need to implement something like this:
Some information about Pawn (such as position, speed, etc.) can be obtained at 200Hz, but an FPS can only be a few tens of Hz (such as 50Hz).
That is, under the condition that normal FPS (such as 50Hz) rendering frequency is guaranteed, the background of each frame needs to set and read the data for 4 times (taking 200Hz data acquisition as an example).
I‘m new to ue, so far all the code I see is updating the Pawn data once every frame (Tick), such as setting the Pawn’s position, etc.
Examples are in the official documentation
// Called every frame
void APawnWithCamera::Tick( float DeltaTime )
{
Super::Tick(DeltaTime);
//Zoom in if ZoomIn button is down, zoom back out if it's not
{
if (bZoomingIn)
{
ZoomFactor += DeltaTime / 0.5f; //Zoom in over half a second
}
else
{
ZoomFactor -= DeltaTime / 0.25f; //Zoom out over a quarter of a second
}
ZoomFactor = FMath::Clamp<float>(ZoomFactor, 0.0f, 1.0f);
//Blend our camera's FOV and our SpringArm's length based on ZoomFactor
CameraComp->FieldOfView = FMath::Lerp<float>(90.0f, 60.0f, ZoomFactor);
SpringArmComp->TargetArmLength = FMath::Lerp<float>(400.0f, 300.0f, ZoomFactor);
}
//Rotate our actor's yaw, which will turn our camera because we're attached to it
{
FRotator NewRotation = GetActorRotation();
NewRotation.Yaw += CameraInput.X;
SetActorRotation(NewRotation);
}
//Rotate our camera's pitch, but limit it so we're always looking downward
{
FRotator NewRotation = SpringArmComp->GetComponentRotation();
NewRotation.Pitch = FMath::Clamp(NewRotation.Pitch + CameraInput.Y, -80.0f, -15.0f);
SpringArmComp->SetWorldRotation(NewRotation);
}
//Handle movement based on our "MoveX" and "MoveY" axes
{
if (!MovementInput.IsZero())
{
//Scale our movement input axis values by 100 units per second
MovementInput = MovementInput.SafeNormal() * 100.0f;
FVector NewLocation = GetActorLocation();
NewLocation += GetActorForwardVector() * MovementInput.X * DeltaTime;
NewLocation += GetActorRightVector() * MovementInput.Y * DeltaTime;
SetActorLocation(NewLocation);
}
}
}
How do I implement such a feature?