Is it possible to set a child actor's class to the parent actor's class?

I’m trying to make a modular house interior building system, it’s pretty basic, the player starts off with one room and can change the size of that room or add other rooms and hallways, the way it works is I have “child actors” attached to the parent actor that I change the class of, this allows me to easily reposition the attached rooms/hallways when the parent room’s size is changed. Now the issue I’m running into is adding rooms next to other rooms, I know why setting the child actor’s class to the same as the parent in the blueprint editor is not allowed because of infinite loops and what not but why can’t I set it to the same class in the gameplay since the actor is an instance of the blueprint it shouldn’t cause an infinite loop to set the child actor to the same class. Is there anyway I can work around this as set the class of the child actor how I want it?

1 Like

I think you might have got the class concept a bit muddled.

I’m not sure why you need a class hierarchy here. You could just have a list of blueprints ( room, corridor, door etc ). And connect them.

If you want to have a class system, then you could have one class ‘building component’, with children like ‘room’, 'door, ‘hallway’ etc. The main class could contain things like attachment point, rotation, and each child would have the actual walls and doorways and so on.

Maybe you can describe how it works a bit more?

2 Likes

These things oftenly happened in portals development.
If you are trying to make a porting system, forget about this it will render every shader you port into sub classes by an infinite value according to the available vision of the camera.

Example

1 Like

Sorry if I didn’t explain it very well, I wrote this at 1 in the morning.
image
The parent actor blueprint has 3 child actors attached to it that are currently set as walls
image
Now the child actors I have set up to change the “class” to the blueprint I need it to be
image
It works well with adding rooms onto the main room since the “MainRoom” is a different blueprint than the other “Rooms” but when I try to replace the child actor on a room with another room it just deletes the child actor all together
image
image
I was saying I know you can set the child actor the same blueprint as the parent in the blueprint editor because it would cause an infinite loop but I should be able to in-game since it wouldn’t cause the infinite loop since it’s just an instance of the original blueprint.

With you.

It should be ok to set the child to room, as long as the default room only has walls.

When you’re setting it in game, it’s just THIS instance that has another room attached.

Is that what you mean?

( I’m gonna try this… :slight_smile: )

Yes, exactly the same… hmmm…

There probably is some good reason for this.

Instead of changing the class, why not add a new child actor with the same transform and remove the old one?

Wow, that doesn’t work either! :sweat_smile: ( I just took the editor out )

Yeah, I’m almost positive it’s because the editor is trying to prevent infinite looping but it shouldn’t cause a loop since it’s just an instance of the main blueprint. Idk, I’ve been playing around with it to try and find a work around but I might end having to scrap the “child actor” idea.

1 step forward, 50 steps back, gotta love game development.

It is something to do with recursion.

Because it’s in the room code that when event X happens, we change this wall to a RoomBP, and this is a RoomBP.

Better off, I think, spawning and destroying actors.