Networking problem with interfaces between actors

Hi all,

I have been playing around with trying and implementing a items/weapon system with multiplayer. Now i have come to realise that my idea maybe is not possible, i have been banging my head against the wall for a day now, i think i have tried everything i can come up with. Please i hope someone can shed some light for me on this one.

I have a “player character” that for now, on begin play just tells the server to spawn and attach a weapon to my “player character”:

In the same player character i have a event on mouse klick that fires a interface message, which is implemented on the weapon that is spawned and attached to my character, well the event actually finds any actor attached to my pawn that has that interface:

The weapon then recevies this interface message, and fires a event, that does 2 traces, from player camera, and then from weapon to where player camera hits, nothing special. If it hits a actor that implements another interface “On Hit”, it just calls that interface message:

On Hit event in turn, on the enemy actor this time, just tells the authority to change the health value, wich is onrep notify, and that onrep function just changes some text above the actor.

Here is the catch, this works, if and only if I call the On Hit interface message from my pawn directly, and if i go the way above, it only works for server, and not the client. For me it seems like some kind of ownership problem, but to be honest, i dont know anymore. Is this even a possible design?

for you wondering why this design, i wanted to separate everything. player pawn does not have any idea what its holding, it can be a gun, healkit, building tool, whatever. It just “uses it”. The actor itself that is a weapon in this case, could be anything, and the logic inside it decides what it does. And in the end, the enemy, it self decides what happens, when it gets hit. Good? bad?

Thank you.

I’ve just rewired my base character blueprint and added a “use” interface to my weapon to give it a try. It works fine (tested with 1 listening server and 2 clients). The major difference to your setup is: I did not connect the input action directly with the interface call but I’m calling a server event previously.

Simplified to this:
Character BP:

Weapon BP:

Edit: Probably even a further difference. I’m doing pretty much everything in my PullTrigger function after “SwitchHasAuthority”. All that ammo counting, linetracing and finally spawning the projectile is done on the server. I’ve a further function called “PullDryTrigger” where I do stuff that may be done on the client instant (like playing a “pulled the trigger” sound).

Thank you for your kind reply. This is exactly what i am doing right now. And it works. Just solved it with some help from discord ue channel, before i saw your post above. :slight_smile: i was almost doing the samt thing before i changed everything client side, becouse i was trying to figure out what is going on. The thing i did before is, that i started the server logic on the weapon. I still “used” the weapon localy on my pawn, and in the weapon i told the authority to run on server trace and call the interface on whatever we hit. I do wonder though, now that everythign is running server side, i noticed that i cant see my linetrace debug on clients anymore, is there a easy way around that? as use function is called server side from pawn now, everything on the “weapon is server side” thus, remote will never execute?