Multiplayer spawned actor is null?

I spawn an actor on the server, I check if it’s valid (and it is) so I call AttachWeapon (multicast event) and pass the newly spawned actor as a reference. Then I check if it’s still valid in the AttachWeapon event. But now it’s NULL?
Note that the spawned-actor blueprint is also set to “replicate” (movement is not replicated) and that it works on the server but not on the clients.

How is this possible? I spawn an object on the server (I believe that all objects must always be spawned on the server) and then I attach it in all clients.

In the second screenshot I put an IsValid? function before the SET-node and it showed me that it was NULL.

Also the outputlog shows:

LogNet:Warning:
UIpNetDriver::ProcesRemoteFunction: No
owning connection for actor
PlayerCharacter_BP_C_31. Function
SpawnWeapon will not be processed.
LogNet:Warning:
UIpNetDriver::ProcesRemoteFunction: No
owning connection for actor
PlayerCharacter_BP_C_30. Function
SpawnWeapon will not be processed.

But this code is executed inside an actor-component of the player-character. So the player should have ownership. Also I am NOT replicating the playercontroller. Setting the Event SpawnWeapon to no-replication get’s rid of the errors but does not fix the problem.

Try adding “Delay” node after spawning. It takes some time to replicate just spawned actor from server to clients so you might trying to access these actors on clients before they got replicated to them

I know that the run-on-server can only be called from the owner (player or it’s actor-components, playercontroller or player-state). I’m calling this from an actor component on the playercharacter (which is possessed). So I don’t understand why I get these warnings.

I added a 2-second delay between SpawnActor and AttachWeapon but it did not fix it.

I also tried promoting it to a variable and storing it in there instead of passing the reference into the AttachWeapon-event but it didn’t change anything.

But I think the real problem is that error-message. Somehow the game doesn’t like me running the SpawnWeapon-event on the server it seems because as soon as I set it’s replication to “run on server only” it starts throwing me those warnings.

I created a new empty event called “test1” and set it’s replication to “run on server” and that one too threw me the same warnings. So even an empty event is already a problem.

LogNet:Warning:
UIpNetDriver::ProcesRemoteFunction: No
owning connection for actor
PlayerCharacter_BP_C_3. Function test1
will not be processed.

But this is an actor-component attached to the player-character. I do not understand why I get these errors. So I tried adding a “custom event that runs on the server only” directly to the player character:

Again the same warnings… I do not understand. And it seems that both characters (server and client) throw those warnings and they are both possessed.

Does spawned actor market for “relevant to all” ?

Also, you can set variable “active weapon” on server and ue4 would replicate it all over network. No reason to multicast this part.

Does spawned actor market for “relevant to all” ?

How do I make sure of this? The relevancy range is extremely high and this code spawns a weapon in the hands of an actor which stands near the spawn-area meaning that the distance at least should not be a problem. I also tried checking “always relevant” on the weapon and I never manually set “only relevant to owner” anywhere.

Also, you can set variable “active
weapon” on server and ue4 would
replicate it all over network. No
reason to multicast this part.

You are right. The variable ActiveWeapon already appeared to be set to replicate. I removed the multicast on AttachWeapon and set it’s replication to “None”. But the problem persists.

I believe that those yellow warning messages are the hint to the problem somehow. Like why am I not allowed to run an empty server-only-event from within the player (or it’s actor-components)?

Does weapon spawns on every client?

Every player spawns a weapon when that player chooses to equip it. It works for the ‘server-player’ but not for the ‘client-player’. Then that weapon get’s attached to the player-mesh. And yes every client starts out with a default weapon (which is also spawned with this same code and that code strangely works) but switching weapons does not work.

I did notice that changing the SpawnWeapon from “runserveronly” to “run” or (no replication at all) (which is wrong but okay) did spawn the weapon for the client but not for every other client/server (they didn’t see the other player equipping the gun). And setting it back to “runserveronly” will only make it work for the server-player.

Ok, So i assume when you change weapon in main slot, you destroy or hide previous one as separate event, probably in weapon code itself. Within this context, spawning new weapon is two step action:

1)On Server : Spawn Weapon Actor and Assign it to RepNotify variable “Main Weapon”

2)On RepNotfy Main Weapon event attach weapon.

No Owner Warning is probably there because you call owner events from other clients in network.

Closing the question because I removed the code and went for a better overall-design of the code/blueprints. I still don’t know why this code didn’t work though but the question is no longer relevant.