The problem isn’t the axis or rotation. Is probably how the problem was approached after the initial tutorial.
lets assume a few things you can easily replicate.
- create an actor called door.
- add a mesh to it.
- add a custom event. Call it open.
- ads a custom event. Call it close.
- create a timeline.
- right click type self. get a reference of self variable.
- drag from it and type transform. find the one that best suits your needs - you need to set, not get.
- split the transform pin.
- slept the rotation pin.
Here you just opened up the axis value on which you can affect the rotation you need…
double-click the timeline, and set it up.
you probably want a total speed of .25 (quarter second) or more. Make sure to set both the duration of the timeline and the timeline values by adding key frames and placing them appropriately.
Place the last key frame at a value of 360 - for now. A full circle.
drag from the self pin, type transform and find a matching value for the get function. Split its structure pins again.
drag from each axis and create a variable. Call them f_rotationX, f_rotationY, and f_rotarionZ
set these value (connect the exec pin) out of bot Open and Close (each needs its own set so duplicate and connect the set operations).
plug the last set pin exec to the timeline.
use Play from the open event, and Reverse for close event.
Now connect Update to the set transform. And let’s get ready for some math.
create 3 bools: b_rotateX, b_rotateY, b_rotateZ. Set all except X to false.
drag from any float of the rotation split (set or get, same thing for now) and type select. This should generate a select float. Requiring a Bool to power it.
connect the get of each bool you created to a select float.
connect the GET rotation to the B value of the select (if false, use B, the original rotation).
also, connect the output to the relevant rotation axis of the set function.
do the math.
take the initial rotation value, add the timeline output to it.
plug into A of the relevant select float.
To handle closing, you need to check the timeline direction (it’s an emum pin that’s part of the timeline).
when Clsoing, the value needs to be subtracted from the initial rotation.
when opening (we handled it already) you need to add…
to do this, another select float, and a branch will probably do the trick. Run both add and subtract.
let the select float handle the proper value.
Inelegant, but easy to setup…
That’s basically it. you have a door that turns around whatever it’s pivot point is (set by the scene component) by 360°, and back around when you call the respective functions.
- adding variables to limit the swing of the door.
Take the last result of the select float, drag and type Clamp.
in the clamp, drag the Min and the Max and create proper floats.
f_min_rotX, f_max_rotX etc.
Expose those values like the bools.
And pin their get to the respective spots.
perhaps pre-set the max values to 125 or thereabouts.
Now you can make another actor, call it closet, and add a door actor to it - as a child actor.
Place the child actor, position, set its values, and choose how to transmit the open/close calls to it. Blueprint interface is probably great for this.
would need another 10 entries or so to adjust for that though.
At a base level, just make another custom event in the main actor, call it Open, mark it as blueprint callable.
Take the child actor reference in the code, drag from it, cast to the door class, and from the cast success, call the Open event.
Repeat for however many “doors” the object has.
then while the game is playing in PIE, eject, click the actor, and find the button for the BP callable function (event) in its details. Click it, and test out the open /closing of doors.
this is also where you fine-tune the angle on a per-instance basis by altering each child’s rotation options.