Critical Issue: Server RPCs Dropping for Server-Owned Weapon Actors in Unreal Engine Multiplayer

Each controller on the server is linked to a corresponding client controller (they have the same NetID), except for the listening server controller (he doesn’t need it).
So yes, a single controller on a server is the same as a controller on a specific client.

If it is “not that” controller, then the reference on the client will be invalid, since clients do not have access to other players’ controllers.

If the reference is valid on the client, then “IsLocalController” for that controller should also return “true”.
Is that the case for you?

1 Like

For instance, this code running whenever the player click on the client always trigger Weapon has no valid PlayerController owner!:

	APlayerController* OwnerPC = Cast<APlayerController>(GetOwner());
	if (OwnerPC) {
		// Check if the owner is the local controller
		if (OwnerPC->IsLocalController()) {
			UE_LOG(LogTemp, Log, TEXT("This weapon's owner is the local controller: %s"), *OwnerPC->GetName());
		}
		else {
			UE_LOG(LogTemp, Log, TEXT("This weapon's owner is NOT the local controller: %s"), *OwnerPC->GetName());
		}
	}
	else {
		UE_LOG(LogTemp, Warning, TEXT("Weapon has no valid PlayerController owner!"));
	}

The Owner is correctly changed on the Server but not the Client, which is really weird to me… It’s like if the replication doesn’t actually work (OnRep_Owner() doesn’t trigger either, which explains why the client Owner doesn’t change… which is a problem)

Can you make an RPC event that any client can call and try to call it from each client?
As I said earlier - clients do not have access to other player controllers and therefore the reference will not be valid, the GetOwner function on the client will return null if the owner is another client.

1 Like

I’m not really sure what you mean here…

I just fixed it!

I made the dumb mistake to forget to call Super::GetLifetimeReplicatedProps(OutLifetimeProps); , it’s so dumb but that will NEVER happen again lol… Took me 3 days!

Thanks for helping me!

1 Like

LMAO it’s literally me :laughing:
Sometimes I spend a lot of time on problems that don’t exist. Or what’s worse - which I myself, without knowing it, created.

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