Networking code isn't working (Please help)

I’m not a complete noob to network programming in UE4 iv’e already made some basic code like spawning actors on server etc, but my current code just isn’t working and i have no idea why? Iv’e recently upgraded to UE4.7.1 (non-source) so i don’t know if that’s conflicting with my code or what?

I have made an item that the player is supposed to pickup, when the player triggers the pickup function it will call a server rpc to add the item to the players inventory and then destroy itself. But it just isn’t being called. When i force call the server rpc in BeginPlay() it crashes, and when i call it real-time nothing happens? (My code compiles successfully with no errors or warnings)

cpp



bool AItem::ServerStartPickup_Validate()
{
	return true;
}

void AItem::ServerStartPickup_Implementation()
{
	PickedUpBy->AddItemToInventory(Cast<AItem>(this));
	Destroy();
}


Header



UFUNCTION(reliable, server, WithValidation)
		void ServerStartPickup();

	virtual bool ServerStartPickup_Validate();
	virtual void ServerStartPickup_Implementation();


Thanks to anyone who wants to help :slight_smile:

RPC only works if the client is the owner of the object. I suppose in your case the owner is the server. The client usually only owns the PlayerController, PlayerState and (maybe) his Pawn.
You want to run the pickup function already on the server. When is it called? Maybe you can move the RPC to the player controller?

Oh ok, Thanks ill rethink my code. :smiley: