How to make CLIENT side Beams less "shaky"?

The beam is just two actors: SourceBeam, and EndBeam.
SourceBeam is spawned and attached to the barrel of the turret.
EndBeam attached to SourceBeam, then has its RelativeLocation set based on the intended length of the beam: FVector(BeamLength, 0.0F, 0.0F)
EDIT:
To be clear, the SourceBeam is attached such that it shares the barrel’s rotation, and subsequently setting the X value of EndBeam’s RelativeLocation is suppose to ensure it is always placed along the firing axis of the barrel, where ever it happens to be facing.

Each tick on the SERVER the beam extends to a max distance, or if a tracehit determines if something is hit extending to the impactpoint instead.
BeamLength is then set based on the distance between SourceBeam and the impactpoint.
BeamLength is then replicated to the CLIENT.
Each tick on the CLIENT the beam extends to BeamLength.

For the most part this works, but if the firing pawn is moving left or right in relation to the target, the end point of the beam on the CLIENT side starts shaking wildly.
On the SERVER everything is fine.

Im assuming it has something to do with latency over the network…
Any suggestions on how to ensure the stability of the CLIENTs end point, would be much appreciated.

I would move the whole beam visualization to the client side, so it can run with zero latency. There’s no need to sync it from the server, it’s just a visual effect.

It is. The effects are spawned in the tick outside of any (Role == ROLE_Authority) checks.
Its just a beam effect that has a source and target equal to the SourceBeam and EndBeam Actors.

I mean, the whole thing with the trace and setting the target point should be done on the client side. You would still handle firing the turret server sided, but the visualization can be 100% client sided as there’s no advantage for cheating it.

Ill try it, but the EndBeam Actor is shaking left and right and the SourceBeam is attached to the barrel(so is always in the same direction), so Im not sure how localizing the trace is going to fix it…

EDIT: No dice. Still shakes.



SourceBeam is spawned and attached to the barrel of the turret.


So does this mean that the Beam is attached to a replicating rotator? If so, not much you can do about it other than smoothing out the rotation updates from the Server.

Actually rotation occurs locally. I replicate an FVector called AimLocation to tell the local weapon where to turn to.
I decided to double check and used DrawDebugLine() to check AimLocation on the CLIENT. It isn’t shaking around.

Im going to double check the code that handles weapon rotation.
Though, it is the same code for both CLIENT and SERVER so I don’t know why it would act different…

ok.
After a long series of tests to eliminate potential cuases, Ive solved my issue.

I noticed that if I used DrawDebugLine() to draw a line directly from the barrel, in the direction of the barrel, for the distance to the target; then there was no shaking.
It seems trying to attach the beam actors to the barrel and relying on the beam actor’s relative locations and rotations to the barrel, wasn’t working. :confused:
So I am just forgoing the concept of attaching them to the barrel, and instead manually placing them each tick with a SetActorLocation() call.

The result is a smooth seemingly perfectly orientated beam regardless of distance and velocity.