Server Authoritive Movement (RPCs)

Hi, I’ve managed to implement networking with a questionable amount of success in my project, but I’ve gotten hung up on the player’s dash ability. I’m getting an error when trying to create a Server RPC which passes in an FVector2D as a parameter. The dash ability can be aimed in any direction, and so needs both axes. What I find weird is that I have a regular, single axis binding that works perfectly fine over the network.

// In MaximumTopSpinBall.h

protected:
	/** Action Bound. Calls server dash with
	FVector2D(left/right axis input, up/down axis input) */
	void DashHandoff();

	/** Axis Bound. Called for side to side input */
	UFUNCTION(Server, Reliable, WithValidation)
	void ServerMoveRight(float Val);

	/** Handle dash action. */
	UFUNCTION(Server, Reliable, WithValidation)
	void ServerDash(const FVector2D AxesTilt);

(Line 46 of MaximumTopSpinBall.h is ‘GENERATED_BODY()’, if that helps.)

I’ve tried having the ‘AxesTilt’ stored as a replicated UProperty, but when I tried creating a ServerSet RPC that takes in two floats for that, I got the same incompatible error.

I can’t figure out how to make this work. Can I not use parameters with RPCs? Why is ‘ServerMoveRight’ accepting a parameter when nothing else will?

I… have no words. I’ve been hung up on this for a day and it just compiled with 0 errors. The error still shows up in VS, but it compiles.

Okay then. I’ll leave this here in case anyone else runs into this problem, or someone wants to look at fixing it, but I feel kind of stupid right now.

Hey there,

Try setting your parameters (in the header and source file) as references. :slight_smile:

Example:

	UFUNCTION(reliable, Server, WithValidation) // Called on the client executed on the server
	void ClientRPCCFunction(const FString & S_String);

	UFUNCTION(reliable, NetMulticast) // Called on the server executed to all the clients
		void ClientFunc(const FString & C_String);

Ah, this seems to fix the underline error in VS. Thanks.

No problem. Just be sure to mark it as answered so other folks searching will know how to fix their issue when they search for this. :slight_smile: