Client trigger events are not reflected to server platforms

When I overlap with the trigger box in the server, moving platforms start moving in both client and server. But when I do it on clients they are only moving on clients. How to make the client trigger events to reflect on server moving platforms as well?

Hi Tony,
First, let me welcome to you the community. I hope you’re enjoying the course so far.

When you want to control moving of the platform, you really want the server to control movement and have the client update from the server.

One way to do this is inform the server via RPC calls (later in the course) to start and stop movement. Then, using replicated properties, this will update the position of the platform.

I can’t tell which part of the course you’re on as there’s topics for each video but you may not have encountered this yet. It is covered in about the 10th video.

If you’ve missed something in that video, it’s worth comparing against the end of lecture code which will help you to find the issue.

I hope this helps.

I finished the first section. But I’m using interface messages to activate and deactivate the movement of platforms.
This is how the message is passed from PlatformTrigger.cpp on overlap

void AActivateTrigger::OnOverlapBegin(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)

{

int32 NumOfActors = ActorsToActivate.Num();
UE_LOG(LogTemp, Warning, TEXT("Numbers of actors to trigger are %d"), NumOfActors);
// Going through each array element and passing message  activate
for (auto x : ActorsToActivate)
{
	if (x->GetClass()->ImplementsInterface(UActivatableInterface::StaticClass()))
	{
		
		IActivatableInterface::Execute_ActivateTarget(x);
	}
}

}

And in MovingPlatfrom.cpp this is how message is handled
void AMovingPlatform::ActivateTarget_Implementation() { bIsActive = true; }

this is the condition that is checked in Tick() of MovingPlatform.cpp
if (HasAuthority() && bIsActive)

bIsActive is declared like this where OnRep_bIsActive does noting
UPROPERTY(EditAnywhere, BlueprintReadOnly, ReplicatedUsing = OnRep_bIsActive, Category = "Platform") bool bIsActive;

When I overlap a trigger box in clients they are not moving at all. Only overlaps on the server are getting replicated.
Is there anything else I need to do?
Thanks in advance for your help.

Hi Tony,
So sorry for taking so long to get back to you on this.

I reviewed my code and what I have is the following:

OnOverlapBegin and OnOverlapEnd were both defined as UFUNCTION().

The following should be in the constructor of AMovingPlatform:

SetMobility(EComponentMobility::Movable);

Also the following code in BeginPlay

	if (HasAuthority()) {
		SetReplicates(true);
		SetReplicateMovement(true);
	}

Consider simplifying your code until it works - remove the interface checks until you know what you have works.

I checked against the code in the itch.io lecture and mine matches so you can use that as a reference to ensure nothing has been missed.
Give that a try and let me know how you get on.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms