Modular Blueprint Design

I’ll summarize my problem here, but I also made a quick youtube build going over the problem here:

https://www.youtube.com/watch?v=1HubCnOMzQw

The video will explain the issue, and what we are trying to achieve a lot better than my wording below.

In our game, the player can design almost any type of piston petrol engine. We have created a series of modular engine pieces, so to design a V6 or a V12. We put a front engine piece, x middle pieces, and an end piece.

As engines have moving parts, e.g. valves, valve springs, camshafts, lobes, rocker arms etc. And the timings of when these components move depends on the engine type and cylinder number for the components. We need someway of setting this information within the blueprint editor.

The crux of the problem is. We have the sub blueprint of a middle piece, containing the moving parts. Then the engine blueprint, containing x copies of the middle piece, placed correctly.

The problem is, unlike the UMG/Widget system, UE Editor can’t derive the types of BP’s placed in BP’s. They are hidden behind a ChildActorComponent. No variables within that BP can be set from the owner BP in the hierachy.

This can be achieved through the graph editor (Get Class Actor → Cast → Get Variable → Set Variable etc). But we have over 60 Engine head types to build. And this is a very cumbersome method. The other method we have tried, and appears to work. Is create our own custom EngineActorComponent, and EngineActor base classes. The EngineActorComponent can then pass through the data, and the BP editor can see the Properties on the EngineActorComponent and set them. This works fine, but is still a cludge.

Is there something I am missing?

Honestly, this sounds like you’re using ChildActors instead of SceneComponents - which are the correct construct to use for “Sub-actors with a relative transform”.

Please note, however, that while scene components cannot properly contain other scene components, they can have other scene components attached to them:
So the hierarchy would work like this:

Engine
→ HeadPiece
→ EndPiece
→ MiddlePiece
→ MiddleSubPiece1
→ MiddleSubPiece2

(To properly spawn and attach components at runtime, see: What is the correct way to create and add components at runtime ? - C++ - Unreal Engine Forums )
Else, if you really need everything to be actors, consider just using variables (of the base type, or if you need even more abstraction, of interfaces).

All in all, you’re probably in need of a good book about composition vs inheritance more than UE4 specific advice.

ChildActorComponent is also SceneComponent

You can access actor contained in ChildActiorComponent via ChildActor varable in it, you can see it here, blue note icon mean it’s accessable via blueprint:

You might not know how to access external varable, to do so grab object link (blue one) and drop it on empty space, in context menu there will be Varable category and all Set and Get nodes of all public variables in the object

Also as aureon hints, if you not plan to use those actors other then in components, you might consider using creating component it self, it a lot easier to operate this way, or else component class is too limiting for your solution.

Also UMG “components” (which are not really components) are normal widgets and what you creating is a another widget that can compose other widgets in it, that why normally you can add them together :slight_smile: where actor components are complitly separate classes, because components describes and compose the actor it self, ChildActorComponent was made to make actor work like a component if wished and it works as a container of a actor that why you can’t call actor functions directly from component.

Well, technically - but it’s only a wrapper around an Actor, to which no easy access of subproperties is granted.