Best method to communicate between actors forming a whole object in game?

Say you have a car composed of multiple actors for each part (like a door actor, wheel actor, radio actor etc.), all attach to the body of the car, for example. I have timelines in some of these actors that I need to wait for before I run code in a different actor.

What’s the best way to approach something like this?

lots of solutions to this but an easy one would be to use GameplayTags on the root actor and listen for Tag events. So each component can add a Tag when its ready and when any tag is added check if all required tags are on

1 Like

“Tag events“?

So create a GameplayTagContainer

Create functions that Add/Remove Tags to that container which also calls an EventDispatcher with the GameplayTagContainer as an output.

Then anything can bind to that EventDispatcher, check if the Container has AllMatchingTags and if true execute an event.

Thanks. What do you thing about state trees? Could that be a better option?

havent tried them extensively yet, i dont think they suit this task but could of course be made to work

1 Like

My advice is to communicate directly.

First those parts (door, wheel, radio) sound like components instead of actors. Actors create an overhead and assume independent movement. You won’t be moving the radio or the wheels independently of the car right?

The car is a car because it has 4 wheels and 2 doors etc. Not only that but there are probably no wheels running around without a car. The car already has the pare references (regardless if they are actors or components) and the part can get the car reference on begin play.

From that point on just call methods on the parts and the car directly - they are one entity. Parts can even have references to other parts if they communicate too often. This will make your code faster and more readable but you won’t be able to separate the parts. To be honest, I don’t think you would want to separate them anyway.