Download

Component, that generates other components while editing in viewport

Hello guys.

I am playing with UE, trying to work on top-down game (maybe something Diablo-like) in urban setting.

I would really use having scene component that generates other static meshes depending on some variables (example WallComponent that get numbers of segments and generates wall from pieces), but also acts similar as StaticMeshComponent (I can move, rotate and scale it).

Is something like that possible?

I tried inheriting from SceneComponent, but that doesnt have constructor in Blueprint, all I accomplished was creating meshes on BeginPlay (but that was really hard to place to right location).

I am fine with C++ and Blueprints.

@Salo666666 No problem. You need to make a BP which contains all the meshes you might need, and use the construction script to configure them randomly and according to your requirements. It’s just an actor BP.

I’ll need a bit more info if you also need more…

Hi @ClockworkOcean, thanks for suggestion and sorry for late response, I did not have much time for UE last months.

If I understand that correctly your solution, it wouldn’t allow me to use editor to reorder parts of actor.

Simple example:
UWallComponent that inherits from USceneComponent with NumberOfSegments and StaticMesh as parameters.
(In fact, it would be very similar to InstancedStaticMeshComponent, but instances transforms will be generated automatically)

Than I could use that component in BP editor to construct bunch of BuildingActors.
Each Wall instance would have own transform, so I could rearrange tham in Viewport and quickly create multiple buildings.

Something like this:

Capture.PNG

Ideally, there won’t be any coupling between Component and Actor.

Here’s a simple example:

ezgif.com-optimize.gif

BP:

Looks nice, but is it possible to have that as SceneComponent and not as Actor? Than I could compose then for more complex structures.

I don’t work in that way, so don’t really understand the subtilties of your requirements. Have you see this vid about procedural building generation?:

https://www.youtube.com/watch?v=J5LXIApQmzA

or

https://www.youtube.com/watch?v=_qVXrVV-ipc

What I wanted to achieve was simply have some building blocks (Wall, Floor, Roof) as components and then use them to create Actors (same way as using StaticMeshComponent in Actor blueprint).

Only way I found so far would be to create each type as Actor and use ChildActorComponent.

Anyway, thanks for videos, going to check them.

I forgot to mention, something you might also find useful:

Well most of this solutions are about Actor being put to world (building, etc.). I am trying to have building, where walls or roof hide after character enters, So I would prefer to have everything in single blueprint, which I would than drop to world.

Something like:


- RootComponent
    - Wall1
    - Wall2
    - Roof

Each Wall will be created by repeating same mesh and would have its own Transform (and other properties), so I would be able to move them around in viewport (blueprint eeditor) and assemble single unique building from them.

Right, but the final thing you place in the world will be an actor?

Yes,

this would only allow quicker creation of Actor (with additional logic in BP). Instead of having to add 40 wall segments I would only add 6 walls (for example).

Ok, so you can just make it a BP with components in then. I’m afraid I’m missing a subtilty here…