It just Will Not execute the RPC.

Hi All,

I really feel like I have exhausted all ways to get this to work. I’m at the end of the wit. No more wit.
What I want to do is just what everyone else wants. :slight_smile: To call an RPC on an Actor to execute on the server. The RPC is a spawn. The resulting new Actor will replicate back to the Client.

The Actor Object To Make the Call(named ‘Console’) is itself spawned on game-begin on the Server and replicated onto the Client. This works fine.
I am using the default UE provided PlayerController, ie I don’t have my own derived class for this.

My Console’s .h has this:


UFUNCTION(Server, Reliable, WithValidation, BlueprintCallable, Category = My_RPCs)
		void Server_RPCSpawnStream();

APlayerController* PC;

UPROPERTY(EditDefaultsOnly, Category = TextureController)
		TSubclassOf<class AMyTextureControllerA> TextureControllerClass;


The Console’s .cpp has this in the creator:


PrimaryActorTick.bCanEverTick = true;
bReplicates = true;
bReplicateMovement = true;
bAlwaysRelevant = true;

The Console’s BeginPlay has this:


Super::BeginPlay();

// to get local player controller to set Actors(this) owner to.  Client needs to own Actor to enable to-server RPCs.
for (TActorIterator<AActor> ActorItr(GetWorld()); ActorItr; ++ActorItr)
{
	APlayerController* PCtmp = Cast<APlayerController>(*ActorItr);
               
        if (PCtmp)
	 PC = Cast<APlayerController>(*ActorItr);
}

if (PC) {
    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, PC->GetName());
    this->SetOwner(PC);
    GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, this->GetOwner()->GetName());
}

// setting this so I can do to-server RCPs
SetAutonomousProxy(true);
ENetRole const ActualRemoteRole = this->GetRemoteRole();
if (ActualRemoteRole == ROLE_AutonomousProxy)
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("ROLE_AutonomousProxy!!!"));

As I understand it I should with this be able to execute On-Client-To-Server RPC calls from this object?
I have then tried to execute an RPC both using code and blueprints.

In Code I have this function which I have tried to execute in my ‘Console_BP’ blueprints own blueprint section.


void Console::Server_RPCSpawnStream_Implementation()
{
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, TEXT("Client RPC Call!!!"));
	
	FVector Location(0,0,0);
	FRotator Orientation(0.0f, 0.0f, 0.0f);
	AActor::GetWorld()->SpawnActor<AMyTextureControllerA>(TextureControllerClass, Location, Orientation);
} 

I have also tried to just execute a print on the Console’s Blueprint like this:
It prints the ‘Hello’ but not the ‘Cucku’. Shouldn’t it at least be able to print the text? I have also tried to link in the function from my code ‘Server_RPCSpawnStream_Implementation’.
[http://i.imgur.com/4vxymm7.png](


)

Now I don’t know what I can try to make this work?
At first I wasn’t doing anything to set the Client to own the calling object (the ‘Console’) but I feel like I have now done that with the above code?
It executes fine on the Server and the spawn happens and it replicates fine to the Client. But it just won’t do it from the Client instance.

I want to do this in Code mainly. The blueprint was just because it was easy to get my input working.

Grateful for any ideas??

Cheers, F