Best practice for moving actors with others?

I been building several components for a ship, and probably did so without thinking out how i put everything together in the end.

My ship will move in the level and needs everything on it to move together with it.
My ship have several blueprint actors on it that is interactable.
Several of this blueprints effect other blueprints that i have linked with public arrays to certain blueprints defined in the editor.

My plan was just to add this to my ship blueprint as child actors but noticed i can’t change public variables this way.

So now i’m not sure how to build everything in a nice and clean way, of course i can add hundreds of buttons, switches manually to my ship BP but that is gonna end up messy.
This might be the way i need to go but i prefer a clean reusable setup where i just have my BP_Button and link that to lets say BP_Engineroom_light1

TLDR: is it possible to make Actors move with another actor like they are fused together?

The best way I know is to have everything as child actors. Have you looked in to Blueprint Communication and Event Dispatchers?
Blueprint Communication Live Training: (Excellent) Blueprint Communications | Live Training | Unreal Engine - YouTube

I would also look into learning how to use Actor Components: Using BP Components for Game Behaviour | Live Training | Unreal Engine - YouTube

Can you give some more details of these components and their interactions? Is this a First Person view inside ship? Third Person view of ship? What type of gameplay?

You should be able to set public variables on child actors, you just need to do it through blueprint communication, I have a Thrust_Flame blueprint and multiple copies of this as child actors, and when I need to update the size/color etc. of the flame, I use an Event Dispatcher on the main Ship Blueprint. The Thrust_Flame Blueprint binds to the Event Dispatcher on the main Ship Blueprint. Then, my Movement Actor Component (Custom, not the Unreal built in Movement Component) calculates the thrust vector, calls the Event Dispatcher on the main Ship Blueprint passing along the Thrust Vector, then the Thrust_Flame Blueprint sets it’s variables accordingly. Now that I say this, I guess it is not really one blueprint setting a public variable, as the child actor is receiving a message and setting it’s own variable.

I believe to set a public variable, you would have to get a reference to the actual actor in the World Outliner, and the difficult part would be getting that reference from another blueprint to set that variable.

Otherwise, to attach an actor to another actor, in the World Outliner, just drag and drop the actor over top another actor and it should say “Attach…”

294628-world-outliner.jpg

You can attach actor at runtime via blueprints as well:

294629-attachactornode.jpg

Hope this helps.

Looking back at my spaceship setup, I created individual blueprints for each weapon, which contained all the variables and functions for that particular weapon, and then on begin play, the weapon blueprints are attached to the main Ship Blueprint. This way I was able to get references to each blueprint and set/retrieve variables and call functions.

Thanks, i think that pretty much sums it up! Tried the attach method and it works, big thanks! the only problem i see here that in the end i would have a really messy world with a lot of assets like probably over hundreds of them that belongs to just one of the ships.

I looked at Event Dispatchers but let’s say i have 10 ships, would not turning off the power in one of them affect all other? Then i would need to to specific BP to every ship.

It’s a First Person view inside the ship.
I have different blueprints for interaction, like a light switch with animation/moving parts. That’s then connected to my engine blueprint etc, i have doors and so on. Everything is connected to the power and to other played controlled options.

Did you watch the video on Blueprint Communication?..So, you have light bulbs A,B,C,D in ship “Betty” controlled by switch X. Switch X would have Event Dispatcher (ED) called “Flip Lights”. You have one Light Bulb Blueprint (BP) with variable “Switch” which is of type “Actor”. Now you can put lights A-D in your scene, set the variable to reference Switch X. You have some sort of trigger, such as pressing Spacebar, on Switch X, which calls the ED on itself. Your Custom Event on your Light bulb BP would then use the Flip Node to trigger the Activate or Deactivate event. On Activate, turns on, on deactivate, turns off.

Blueprint Interfaces work in somewhat the same way, but also allow your lightbulbs to run different code when triggered by same event. So, you create a blueprint interface, then on your BP Class Settings under Interfaces add the Interface, you would add that interface to all BP Classes that would call or rceive functions in that Interface (an interface has functions, so you can create many different functions to call, compared to an ED calling a single chain of events). So, now, your switch and your light BP both have the “Lights” interface on them. Your interface has a function Activate, and a function Deactivate, and a function Explode. Via your switch BP, you can call any of those functions, and everything with that interface will run those functions, however, you can create different behaviors for each BP instance. So you could have one lightbulb, that when activated, it would actually explode, or your switch could call explode, and all the lightbulbs that have code running in explode function would explode at same time. Make sense?

When you have a lot in your level, use the search bar to find actors you need. You can also close and expand hierchies to make it easier to read the outliner

Don’t forget to mark the question resolved by selecting the answer :wink:

Yeah watched it now was a bit busy during christmas, really great thanks man can say thanks enough for this its been super helpful!