Download

Client function is running on the server instead than on the client

In the BeginPlay of the playercontroller I create an object in this way:



m_myobject= ConstructObject<UMyClass>(UMyClass::StaticClass(), this);

// this will only run on the server as the client doesn't have a game mode object
if (AGameModeMultiplayer* gameMode = Cast<AGameModeMultiplayer>(GWorld->GetAuthGameMode()))
{
     if (m_myobject)
     {
          m_myobject->InitializeMyObject(this);
     }
}


it is created on both server and client. The object is declared in the playercontroller header like:



UPROPERTY(Transient)
class UMyClass* m_myobject;


inside InitializeMyObject I have the code for calling an initialize function on the client:



... stuff...

void UMyObject::InitializeMyObject(AMyPlayerController* owner)
{
     m_owner = owner;
     //...stuff...

     // by debugging I can see the server reaches and calls this function
     ClientInitializeMyObject(m_owner);
}

void UMyObject::ClientInitializeMyObject_Implementation(AMyPlayerController* owner)
{
	// BY PUTTING A BREAKPOINT HERE I CAN SEE THIS IS NEVER CALLED ON THE CLIENT BUT IS CALLED ON THE SERVER
	m_owner = owner;

	...stuff...
}


the client function is declared like:



UFUNCTION(Client, Reliable)
void ClientInitializeMyObject(AMyPlayerController* owner);


is there anything wrong with this?
my problem started after the integration of unreal 4.4 but i am not sure if something has changed or if I am just doing something wrong here.
I have other client functions in this object and in other ones and they all have the client functions not working.

I also tried setting up something like this and calling TestFunc from the client:



UFUNCTION()
void TestFunc();

UFUNCTION(Server, reliable, WithValidation)
void ServerTest();

UFUNCTION(Client, reliable)
void ClientTest();


the result is all the three functions are called on the client.