UDP data, jittering

Hi, I have a simple UDP listener set up in UE4. I connect on BeginPlay, and every tick I run this:

if ( ReceiverSocket->HasPendingData(bufferSize)) {
	
		uint8 *buffer = new uint8[(const uint32)bufferSize];
		int32 bytesRead;
		ReceiverSocket->RecvFrom(buffer, bufferSize, bytesRead, *targetAddr);

		FString str = FString(bytesRead, UTF8_TO_TCHAR((const UTF8CHAR *)buffer));
 
            float yaw = FCString::Atof(*str);
}

It works fine, But if i assign the yaw value as a rotation, the animation is ‘juddering’ and not smooth.
It looks like this line:

FString str = FString(bytesRead, UTF8_TO_TCHAR((const UTF8CHAR *)buffer));

hit the fps pretty hard, which could be why.

Is there a straight uint8 * to float conversion i should be doing here?

*edit: I have also tried threading the UDP streaming, and calling the values from the game thread. I see the same Juddering / jitter in the data.

I have a test case where I send an incrementing float. The received values print correctly, and look fine. But when i assign it as a rotation, the animated object staggers/judders.

How can I get this to rotate smoothly?

Thanks!

packets won’t come to other machine in stable time the ferther from server the more unstable ping can make things even more buggus + UDP does not guaranty that packet will reach destination so there possible data loss (but for your solution this should not be a problem). It’s main reason why most software buffers network streams to stabilize flow of data for feather processing. Games solves this problem by letting client do the visuals (like just giving start position and speed and possiblity sync it again ober time) it also reduces unnecessary bandwidth, then the position is being validated with and in case of interaction then the state is being validated with the state on server. UE4 replication system should deal this for you, so why yo not just use it?

Hi, thanks for this. I am streaming data in from an external sensor, so I can’t use the replication. So would buffering the stream help me here?

I am testing with a c# udp programme, that sends one number, counting upward, as a string. When I print the received value, it looks right, the numbers are incrementing as expected. But when i assign it to an actor (either with an anim BP, or by reading the values from the thread and SetActorRotation, I see the judder.

Ah i see :> then alternatively you can try to smooth it out with code, i don’t know what kind of device it is but buffering cause lentecy too. You say you use anim BP, then issue might be there, look on data which device sends and see if there something that may cause such behavior, you can try ignoring some data