Download

Network first person firing

I am trying to get my first person shooting working over a network. I have the following methods:


	
/* Called when a player clicks */
void OnFire();

/* Request a shot to the server */
UFUNCTION(Server, Reliable, WithValidation)
	void requestShot();
	void requestShot_Implementation();
	bool requestShot_Validate() { return true; };



When the OnFire() method is called locally, it simply calls the requestShot() method (notifying the server of the shot request).




void AFirstPersonShooterCharacter::requestShot_Implementation()
{
	if (Role == ROLE_Authority)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString::Printf(TEXT("A shot has been requested")));
	}
}



Firstly, the debug message in requestShot() appears on all instances of the game, event the clients (when running in the editor with players = 2)

Secondly, is this the “correct” way of performing actions such as this in UE4 networking?