Question about Player Controller and Networking

Hi all,

At some point I thought I understand how to handle replication, but I am more lost then ever. Here is quick description of my setup, I will get to the question after:

I am using PlayerController to handle inputs (Enchanted Inputs)., here is a quick snippet:
Player Controller snippet posted by anonymous | blueprintUE | PasteBin For Unreal Engine

And this works okay (since I ask for controlled pawn specifically), but I also do a traceline on Tick event in the same Player Controller to check if player is looking at interactable object and I just noticed it executes on every player controller (server + client). Even if I move my logic to player controlled pawn, it will execute for all pawns - locally controlled and replicas.

Also, HasAuthority returns true only on server for all player controllers, which I understand, since the server is owner of these, but is it possible to have a ‘local only’ logic somewhere or somehow?

This is a co-op game, and I do not need server to check everything or to have the whole logic on the server. If client says that, for example, it wants to interact with an actor, server should trust that and replicate the event.

Bonus question: since lots of tutorials rely on server to check the collision (basically everything), doesn’t this make more performance stress on the server? Why can’t we do collision check on client side and just notify the server that we hit something?

the 2 main reasons are cheating and desync since the client will always be behind the server due to lag it’ll get incorrect collisions.

for local coop though nothing should need to be replicated because everyone is on the server.

Thanks for the answer!

I actually made a mistake, its not a ‘local’ coop game, just a coop game.

I still do not understand how should I handle trace for checking if the object we are looking at is interactable. Seems like an overkill for server to trace each character and send an event when client is looking at something that can be interacted with.
Is there a way to do it locally only, for the owning pawn?

yep, use this

but i dont recommend it, you’ll still want server authority, for example if 2 players try to use the same interactable at the same time you could get problems/bugs.

I already do use it, but I wasn’t sure if that’s an okay approach.

Regarding 2 players using an interactable item, wouldn’t it be sufficient to only consider who contacted the server first?

exactly, but that has to be server side due to lag otherwise there will be a brief interval where both can effectively use it

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.