Why is this client function no longer getting called on the owning client?

This was already working before… I moved some of the code into a UObject that lives on the ActorComponent and now it’s no longer working. A lot of code is omitted, but hopefully you get the gist.

I have an actor component UExperienceComponent that lives on my controller. It has a client function.

	UFUNCTION(Client, Reliable)
	void ClientExperienceGained(FExperienceChange Grant);
void UExperienceComponent::ClientExperienceGained_Implementation(FExperienceChange Grant)
{
	OnExperienceChanged.Broadcast(Grant);
}

I’m setting up this callback on the constructor for the ActorComponent:

UExperienceComponent::UExperienceComponent()
{
	SetIsReplicatedByDefault(true);

	Container = CreateDefaultSubobject<UExperienceContainer>("SkillPoints");
	if (Container)
	{
		Container->SetExperienceMultiple(ExperienceMultiple);
		Container->OnExperienceChanged.AddUObject(this, &ThisClass::HandleExperienceChanged);
	}
}

void UExperienceComponent::HandleExperienceChanged(FExperienceChange ExperienceChange)
{
	ClientExperienceGained(ExperienceChange);
}

UExperienceContainer is not replicated; it’s just a UObject that lives on the server.

Basically, I want this client function to be called the on local controller. However, when I call this function it only occurs on the server. Why is this happening?

Jesus Christ… I moved the OnExperienceChanged subscription from the constructor to BeginPlay and it’s all working now.

1 Like