Tick order for components?

Are components guaranteed to tick in the order that they are added to an actor (since we’d want the movement component to tick before the replicator component)?

I found this link which discusses tick groups and being able to explicitly order component ticking with AddTickPrerequisiteComponent, but I didn’t see anything related to the default behavior:

Does it perhaps normally go in the order that components are added, but it’s not necessarily guaranteed?

I wouldn’t rely on order. If you need something executed in order, expose a series of publics in your components and then call the specific methods from their parent object.

It seems the article points to groups but within the groups themselves, probably a free-for-all.

After the decoupling exercise, UGoKartMovementReplicator depends on UGoKartMovementComponent by calling MovementComponent->GetLastMove(). So, depending on what order those Tick methods get called, the replicator might be using information that is one frame old. Obviously, everything will still be functional if that’s the case, but just to save a few potential milliseconds of latency (one could be unlucky and that could be the one frame where someone went from turning left to turning right), I’ve added the AddTickPrerequisiteComponent to my BeginPlay:

void UGoKartMovementReplicator::BeginPlay()
{
	Super::BeginPlay();

	MovementComponent = GetOwner()->FindComponentByClass<UGoKartMovementActorComponent>();
	// Ensure tick on MovementComponent is called before the one here on UGoKartMovementReplicator
	AddTickPrerequisiteComponent(MovementComponent);
}

Of course, I’m not going to be surprised if the course already points this out in a few lessons. I’ve had that happen almost every time so far with questions that have popped into my head…

1 Like

That’s actually an interesting point. I never thought about this before.

Privacy & Terms