In the header file:
UFUNCTION(reliable, Server, WithValidation)
in the cpp file:
ULabBlueprintLibrary::printDebugInfo(HasAuthority(), GetName() + "ServerTest_Implementation " );
And I call ServerTest() Function from playerController, and nothing happened!
I almost go crazy now…help!!!
Server RPC call will work if you call from local client, and from anything that have Client is Owner, since you run from PlayerController this one is ok then.
This function will work when call from Client to Dedicated Server or Client to Listen Server, make sure run your game with Dedicated Server if u run with 1 players only.
they send autonomous unanswered question to my mail box so here i am For you thing like i said only actor or pawn owned by Client can call Client-to-Server function, so normal in Client you only own PlayerController by default, the rest it own by server, so any thing you posses they already call the function SetOwner(YourPlayerController) in server, so if you do like that you need to set owner of the real pawn to your PlayerController or the Pawn you controlled then it will be ok.
hey, see u again. I love u so much!!!
In my game, I have a proxy pawn and player controller manipulate the proxy pawn, and the proxy pawn will then manipulate the real pawn.
Here comes the Weird thing: If I put Server Function on proxy pawn, it works correctly, But if I put Server Function on real pawn, it does nothing.
What’s wrong with it?
I did set the owner of real pawn to the proxy when I spawned it. Still Server Function doesn’t work.
you must call the function SetOwner(AActor*) from the actor class after it spawn. So in your case should be Character->SetOwner(this); Also try to add this one in constructor bNetUseOwnerRelevancy = true;
Hey, I almost went mad… So I created a completely new project from C++ Third Person Template. And I add some code to be able to click a button to call a RPC and spawn a Character, then see if it is owned by the Client, not a simulated one. But I faied, every character I spawned manully has their “Role == ROLE_SimulatedProxy”. Please help me!!
Below is my code.
Oh wait, just saw you have the AI controller on the Character is it ? The moment you set the AI Controller for the Character, Character’s Owner will be Sever again, there is no way Client can own a Pawn with AI Controller, even AI Behavior will run on server only. So basically, you are controlling an AI character through a Server, so my suggest it try to keep all Client-Server RPC on your proxy, and your main Character just gonna be replicated through server, if your Character want to change something just need to ask Proxy to do that for him.
Good idea, That should work.
//PlayerAI = GetWorld()->SpawnActor(GetActorLocation(), GetActorRotation());
But I tried to disable this two line, still don’t own that pawn.