Instancing BPs (actors) as childs of another actor

Hi,

I’ve been trying to design some system for a project I am working on. Spaceships.

I came across this question multiple times:

Why isn’t it possible to instantiate Actors as “Components” without having to go by a predefined “Child actor” that only gets a special type of actor as child.

Here is how my system was built as I was trying to achieve my goal:

Ship [Pawn]

  • BaseNose [Actor]
  • BaseTail [Actor]
  • Base Wings [Actor]

In fact. The BaseNose was, for example, setting up the common behavior of the nose part of the ship. Pretty empty, to be used as a model.

Then there were my Nose1, Nose2, Nose3 that were childs of BaseNose.
There were the specific meshes and behavior of those specific noses.

The problem came in when I tried to swap the different parts.
The problem appeared when I tried to swap the noses.
In fact, it’s impossible to instantiate it on runtime. Or swap it.

I was wondering why It would not be possible to have the actor as simply a child of another actor.
This would make it’s “root” to be placed relatively the mesh/actor/component it’s attached to.
On an event side. It would just be something like “Enabling input” for the actor using the pawn controller.

Wouldn’t it make sense to be able to add any actor as child of another one ?
At the moment, the “Child actor” component is a real problem as it does not allow to define the “Editable” values for that defined child actor.

Also. On a programming standpoint, We could definitely “swap” the part by any other actor deriving from the one used there as childs of this class could only have more function but cannot “delete” a function of it’s parent… (overriding would be ok, it would modify the behavior but would retain the call intact as long as the parameters are all of the same type)
It’s kind of the same as selecting the mesh for a skeletal mesh or static mesh.

I apologize if the question might seem rude. I’ve just been intrigued by the current way this system is working as it’s not friendly at all. Forcing to set up every editable variable within graphs (killing the interest of editable vars there)…
It’s also making “part swapping” really hard and not helping the building of modular setups.

Well. I am open to every workaround and to listen to any other way to achieve this kind of thing. But it’s not as if we could do something like “childactor->setClass(classThatIsChildOfTheClassInTheComponentTab)”…

Thanks for reading.

Tell me if this is for some “future” release or if the system is not intended to change. :slight_smile:

Erio

have you know about “Child Actor Component??”. i think with that component you can set it to any actor class that you had. the problem just it will get destroyed if the parent destroyed.

In fact, yes, and my problem has been to set parameters to it. Or even change the “class” it contains, a little bit the same way you would change a skeletal mesh or particle system template.

Also. I think that you can detach it, so if the parent gets destroyed. It should be alright that way.

The problem with child actor is also that you cannot enter a pin to the class you want to spawn when you use the "addchildcomponent"node. Which makes procedural generations or part swapping impossible for now. :confused:

In UE4, typically you build actors out of components – not out of other actors. While it’s possible to have a child actor via a component, if you were building a spaceship out of modular parts, the ‘UE4’ way of doing it would be using mesh components and other things like that.

It’s probably a bit confusing if you’re coming from Unity, where things in the game world are built out of hierarchies of GameObjects with scripts attached. In UE4, typically you would build stuff out of components inside of a single actor.

One way to think about this is that most actors should be able to operate on their own, as standalone entities in the world. An actor contains everything within itself that it needs to function correctly. Of course, this is not true in all cases (matinee actors, etc.), but it’s generally how you will see things being done.

If you still wanted to build a spaceship out of actual individual actors instead of components, one way would be to simply have a set of points/sockets or empty scene components in your ‘master’ ship actor. Then, using a Begin Play node (or some custom event that follows your game’s own logic), spawn in the actors at the correct points (and now you can use the spawn parameters!) and attach them as children to the scene nodes in the master spaceship actor.

Thanks for your reply.

In fact, I did want to break out the spaceship into different parts to avoid overloading a single actor with 10 thousands of functions while you can clearly say “only the body will do that” or “this only belongs to the nose”.

So the idea was to delegate those specific “part behavior” to those parts instead of having to dynamically generate everything.

At the moment, that’s what I am doing, using meshes and co and dynamically adding adding any attachement using a custom enumeration with custom attach function. (so attaching a beam weapon would add it to the part in the wanted socket and create the beam(s) required by the weapon, deactivating them on spawn and store them in an array that I later use to fire them…)

But somehow. It would have been easier to have the dedicated firing system in the “WeaponBeamBase” BP that you can attach and fire from the spaceship actor. (referencing the different parts of the ship at it’s construction)

Allowing to make clean “parts”, that does not need dynamic creation of elements if you want a specific block-out.

If that’s UE4’s phylosophy, why not. I was just thinking that, taking in account the modularity of the engine itself, its phylosophy would be more looking forward flexibility in the way to use it’s different components. :slight_smile:

Yes, what you say makes total sense :slight_smile:

You can already do this via components in C++ by creating custom components (in this case, it would make sense to subclass UStaticMeshComponent into your own USpaceShipPart component or whatever) but it’s not possible to create Blueprint-based or Blueprint-subclassed components in 4.6. It’s an upcoming feature in UE 4.7 or 4.8.

Cool, I am looking forward this addition to UE4.

At the moment, I could do it with C++, but I want to take the “Full BP approach” to UE4. :slight_smile:

I think that they should expose more things to Blueprints. It’s a good visual Programming tool, I think. :slight_smile:

Let’s wait for this “soon” xD