I simply wanted to build an elevator with multiple floors, each floor has a door, the elevator itself also has a door.
First aproach was just to make a door Actor and a station actor and an elevator actor. Then place 1 for the elevator and one for each floor and wire them up manually.
To make life easier i just want to meld/combine the actors, by placing the door actor in the elevator and also in the station bp, but that seems impossible Using child actor components.
Using child actor components i get weird translations/offsets
I testet different stuff and it seems its not my code that caused these translations.
I also read that ChildActorComponents are buggeg by default, so whats the correct way to create a new reuseable actor from multiple actors. In unity for example i just could create a prefab and reuse it. Spawning the actors by code might work but prevents from editing and posing/moving stuff in the editor.
Child Actor Component (normal child actors working fine but you cannot add an blueprint actor to another actor (at least i dont know how and google dont helps)).
And bugged was what I read and it matches to what my screenshots show: the first image are the doors attached to the elevator by using “Child actor component” the second shows how the door looks in its own editor/placed as standalone bp.
That’s what the child actor component are for. No?
My first thought would be to check the pivot of the child actor component and the actor assigned to it. Maybe reset and reasign the child actor to be sure.
It helped in the editor but when setting local offset via code it seems the whole transform gets reseted to “something” and even the transform of the “child actor component” itself seem to reset. Thats a realy weird behavior.
and when the elevator arrives and the outer doors open they also gets reseted.
I could understand the wrong location because i might have used the wrong function or something like that, but i do not modify the scale (wich also gets reseted).
For opening the doors I use a timeline and the “set relative location” node, which does not alter any scaling.
Also when I stop the game the editor view is weird again.
Shure (if you meant by code would be no problem, i could upload the asset folder), since problem occurs in elevator and also without lets start by the plain doors:
That one is just a wrapper that puts 2 single doors to one double door. It does not has logic, asside from putting the two single doors to the array “Doors”.
Shouldnt the right vector be relative to the objects rotation (right side).
The left side is also weird, one part of the door is moving correctly and the second part is moving in the wrong direction.
Im confused.
In an effort to make your life easier, let’s discuss the design of the elevator system first.
Using child actors provides the advantage of modularity by allowing different functionalities to be encapsulated within separate actors. This enhances the maintainability and scalability of the system.
For an elevator system, it is best to encapsulate the door functionality within a single actor. This actor would manage the door states, such as open, opening, closed, and closing, and handle the door’s movement logic in its relative space.
The main elevator actor would then include the door actor as a child actor, enabling direct communication with the door actor.
A state machine within the elevator actor is crucial, if not already in place. The state machine would manage the various states of the elevator and the door, ensuring smooth and coordinated operations.
The door actor would have its own state machine for its states.
Makes sence totally, and thats why I programmed it like that (or close to that) (the double door is just a wrapper without logic), the door itself has callbacks/events (opened/closed), the elevator reaches a station gets all doors (the elevator doors and the current floors door) and tells the doors to open. The elevator also binds a callback to each door to wait for them until all doors are fully opened. When all doors are open, the elevator enables the controll pad again. On pressing a button on the controll pad it disables it, tells each door to close. After each door is closed it moves to a different station.
Everything works… except for the weird behavior of the child actor components. Before I moved the doors to child actor components even they did work.
But now the transforms or whatever behave weird and it seem to be a bug.
In short:
One elevator (has an array of all connected stations)
n stations
each has a scene containing two doors
each door has the controll logic, 2 box meshes
I did not use a real statemachine if thats an existing item/concept in unreal (would be nice to use). If the state machine can fire events it would be perfect and i might switch to it (thanks)
Maybe im just switching to a mesh with animations and give up on the current implementation.
The idea is to not touch the child actor components or the assigned actor transforms from the elevator actor. From the image in EDIT 3 I can’t tell much, but I’m sure its not the best way to approach a sliding door.
I can share a bp later with what I consider “best” for the door, just to better illustrate the approach I’m suggesting.
Only thing that I did was to scale/rotate the child actor component (not the created actor just the component).
Open/Close are just events in the door blueprint that I call from outwards.
Make your own SM.
Thought it was a ready to use component (aside from animation).
The idea is to not touch the child actor components or the assigned actor transforms from the elevator actor. From the image in EDIT 3 I can’t tell much, but I’m sure its not the best way to approach a sliding door.
Its the code inside the sliding door (same as the link from blueprintue just a small change). The only other way would be an animation (with a mesh), thought a prototype with just boxes is easier. Was a surprise how complicated it is.
Okay the last bug was my fault (the other stuff is still weird), since the doors where non child actors before I used “Attach Actor to Actor” which reseted the transform of the elevator doors (feeling dumb about that one).