Download

Bluprint Multiplayer Cast to Problem

​Hey Guy’s (or Girl’s :wink: )

i’ve got a question. Let me first describe my Project:

I’m working on a multiplayer project in which I want to synchronize the movement of objects.
I have a random generated array of actor references (each time other actors in diffrent variations).
I would now like to start an event in these objects. That usually works via a “cast to actor”.
Is there a way to program this dynamically without querying 50 cast to connections with branch? (I attached a example)

If not, do I have another option? I currently have a widget that calls an event dispatcher in the player controller.
From the player controller I have a Cast To connection to the GameMode (it ensures that another player cannot move when moving)
The movement is in the actor’s blueprint. There an event is first called that runs on the server and this event calls a multicast event that then performs the movement.

Movement in GameMode

Movement on Actor

I’m new to multiplayer, so I don’t know much. My best recommendation would be to look into interfaces if you don’t want a ton of casts. Good luck!

That’s it!! Thank You, a few Tutorials later it works with Interfaces

Hi @Darkslyder90,

Another solution could be to compartmentalize all the variables, events, functions shared between objects into a Actor Component, and Get the component from Base Actor. This will make the code easier to manage and more modular. Instead of repeating the implementation via Interfaces (which are a pain in the a** to troubleshoot with) you implement them in the Actor Component and all the Actors that use it get them.

Interesting view… But Components tend to require more pre-planning though, no?
Whereas Interfaces can be ‘loosely coupled’ into the code anywhere / everywhere.

The thing that makes interfaces a PITA is following / auditing 3rd-Party code flow.
Editor improvements could help tho, as then it’d be easier to ‘cycle through them’.

Just like double-clicking on custom events and being taken to the implementation.
You can do things like append Interface calls with: ‘_Interface’, to help troubleshoot…