Server Code not executing when running NetMode = Play As Client?

Scenario:

I have a CauseDamage function that is set to run on the server and reliable. This works fine in standalone and works fine in listen server for both server character and client character.

They are able to take damage just fine.

When changing NetMode = Play As Client my server code never executes. Its as if there is no actual server running the game. I have put debug statements in the function to alert when its called and confirmed that its called just fine until I am running NetMode = Play as Client, and then the server functions never execute.

I have read through documentation and it says a standalone server is set up behind the scenes, so this shouldn’t be an issue. However it is. What am I missing here?

This only affects my AI enemies hurting players. They can not hurt players when NetMode = play as client. Players can kill enemies and do damage just fine in all three network modes.

How/when are you calling this CauseDamage?

As a client, you can only run Server functions in actors that you own (GetOwner() leads to your local controller, directly or indirectly), so I am guessing you are trying to call AI’s CauseDamage from the client, instead of calling that on the server directly

It is called on a bounding box overlap (which would be on the client yes)
image

image

On Overlap is called in the weapon itself in blueprint:
image

The Cause Damage function is:
image

This being the case if you are saying that the client can NEVER call cause damage, where would cause damage go? It has to be triggered by the bounding box overlap. Where would / how would that code be structured so that a pure netmode client work with it?

Specifically in this example, when a bounding box on the client crosses an enemy, how should the code be structured to notify the server that damage need dealt if this is not appropriate?

It is my assumption that calling on a server function IS communicating to the server that it needs to do this thing or pay attention that a thing has happened.

A NOTE ON ARCHITECTURE
the overlap is on a Weapon object that in this case runs solely on the client. It has a reference to the AssignedDamageAbility (A gameplay ability) and it is that which I call to apply damage, but only if “i have authority”.

Anything that returns true to HasAuthority on the client means that this object only exists on the client, thus RPCs wouldn’t work either.

HasAuthority is only true on the server, unless the object doesn’t exist on the server, then it will be true on the client as the object doesn’t exist on the server anyways

Right. My question is how do you call the server from the client when you can’t use GetAuthority() or GetLocalRole() == ROLE_Authority or any of those tricks because if the character or weapon has been spawned on the client, then the client does have authority over it and I need the server to be notified that it needs to do something.

In this instance, the weapon itself appears to be owned solely by the client, and thus the server has no idea of it. What needs done on this overlap to alert the server that it needs to call this function?

Chat GPT is useless on this matter, telling me to over and over use HasAuthority which does not work. It did have the idea of if I’m on client to call a server RPC call that calls overlap (thus putting context as the server) but I up to this point cannot determine if I am on the client or server and authority is always showing TRUE even though its client (so currently it is breaking)

You should not spawn things on the client if that thing is supposed to be networked (like you weapon).

Spawn on the server, set the player’s pawn as the owner and then you are good to send RPCs as needed (be aware that HasAuthority() will return false for the client).