Box Trace difference Server/Client

Hello,

I’m having an issue where the box trace isn’t the same client and server wise for some reason.

I attach a Weapon Blueprint that has the box collision and trace in it to the Avatar actor character (PlayerController Controlled and owner being PlayerState).

Now when I activate the GA, Server and Client are called and the animation is replicated. However the tracing is not the same. See image below. Now that becomes a problem when the hit is not the same on client and server. Since the client applies a GE and not the Server, therefor not doing any damage.

Here are my blueprint below,

Weapon BP :

Character BP :

Gameplay Ability Blueprint :

Other ScreenShots on what is being printed on screen :

Works kinda

Sometimes Doesn’t

If anyone has any idea please let me know :slight_smile:

Hi, two things you could try:

(-) If you move the box collision by animation, make sure that in your skeletal mesh under optimization → Visibility Based Anim Tick Option you set it to always tick pose and refresh bones (maybe always tick montages will also be enough). Otherwise if its not currently getting rendered on the server, it won’t update there and your box collision won’t move.

(-) Try making your box collision larger. Cause AFAIK by default it needs to be overlapping in a frame, if it moves fast enough or is small enough so that it moves through the object in a single frame you won’t get an overlap.

1 Like

Hello thanks for the reply, so I’ve tried making the animation go a lot slower and there are still not making the same hit detection.

Red is server and Blue is Client

And the tick option is also enabled.

Still wondering what it could be :S. I feel it may be a starting position sync issue or something ?

Did you make sure that the server is not ending the ability before it has a chance to apply the GE? So that its not still stuck in the WaitNetSync while the animation blends out and EndAbility is called.

Otherwise, you don’t need to do any of the tracing on the client. Maybe its easier to find the problem if you only focus on the server and ignore the client.

Well now that you say it, you might be onto something. I’ve noticed that even though the server always starts the ability with “attack” string called on server and client, the “Not touched” string is very rarely called on the server but always does on the client ? I’m still not sure how to understand this behavior though ? Any ideas ?

Also when I put the has authority node before the play montage node, the animation plays on others client but not the one inputing it. (The trace is still done though). So I guess the animation done by the server is not replicated to the client. I don’t know how to fix that though.

One more thing, if I only enable server trace it doesn’t ever apply a GE. Since I believe it’s waiting for validation from client.

the “Not touched” string is very rarely called on the server but always does on the client ? I’m still not sure how to understand this behavior though ? Any ideas ?

From your code I would guess that means that either the OnBlendOut is not called on the server, or the server somehow cancels the ability without going through that path (maybe ServerRespectsRemoteAbilityCancellation is set to true?).

Also when I put the has authority node before the play montage node, the animation plays on others client but not the one inputing it. (The trace is still done though). So I guess the animation done by the server is not replicated to the client. I don’t know how to fix that though.

I usually call the PlayMontageAndWait also on the local client. My point was just that you don’t need to do the tracing on the client, only the cosmetic stuff like animations, sounds and particle systems.

One more thing, if I only enable server trace it doesn’t ever apply a GE. Since I believe it’s waiting for validation from client.

Try removing the WaitNetSync node.

Welp, I mean, I can do the trace on the server only with this setup, it’s just really weird that it doesn’t hit the same spots as the client. Not a game breaker I guess. Thank you very much for your help !

The above is the general flow of things multiplayer wise.

  • Client “faking” action on input… responsiveness etc.
  • Server handles the authoritative action. It doesn’t count unless the server does it.
  • Simulated action. Your sim on other players screen doing the thing.

Thanks for the clarification, so If I understand correctly your point, the client touching is not important at all and is normal behavior ?

The clients traces don’t really matter much in a “weapon swing” scenario like a sword. Only the servers because it’s the only proxy that can calculate and apply damage. Yet you do want your traces to match up as close as possible.

If you swing a sword and it connects on your end, then you’d expect the server to hit the same vitals and award dmg accordingly. They (traces, movement etc) will never be 100% accurate, 100% of the time. Server and Sim proxies are “Approximations”.

End of day context matters. If using traces for interaction, say a door, then the clients trace does matter. It determines whether or not you call the server to do a trace and open the door.

You don’t want to spam the server with pointless calls. For example spamming an input to interact when there’s nothing to interact with. You’re just wasting bandwidth and saturating the network.

So again, context matters.

2 Likes

omg, I spent 3 days trying to fix this and you solved it with 1 click. thank you.

I just made my character skeletal mesh AlwaysTickPoseAndRefreshBones in the
Visibility Based Anim Tick Option