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:
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?
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?
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.