Best way to develop a lever puzzle system?

I’ve been using Unreal Engine for about 4 months now and I’ve started to learn blueprint scripting. I now understand there isnt’s a “correct” way to do things, maybe just a better way for each situation. After watching a lot of tutorials, I’m creating a small horror game inside a manor. I want to use a puzzle system to open a big door. Basically, I have 4 knight armors placed in the level and I want to have 4 levers that make each armor rotate 90º when used. The goal is to get each armor in a specific position, which will unlock the door.
I’d like for the levers and the armors to be separate objects so I can place them wherever i want.

If anyone has done something similar, I’d love to hear a simple explanation of it. Thanks in advance.

I now understand there isnt’s a
“correct” way to do things, maybe just
a better way for each situation.

Nicely put.

Basically, I have 4 knight armors
placed in the level and I want to have
4 levers that make each armor rotate
90º when used.

You could, sure; but you can still do it even if both elements are a part of the very same actor and it makes the communication much easier! For example:

This is my knight and its lever:

When I’m ready to move things around, I can:

  • move the entire actor
  • move just the knight mesh
  • move just the lever

Image from Gyazo

This way, each lever is connected to the specific knight from the get-go.

Image from Gyazo

If you wanted each lever to be a separate actor, you could make it a Child Actor Component instead of a Static Mesh Component.


Alternatively,

  • create a Lever Actor
  • create an Instance Editable Lever-Type variable in the Knight actor

  • you can then connect what you need in the Level Blueprint:

Here, the yellow boxes are the lever actors and I hooked up the far right knight with the far-left lever:

Image from Gyazo

When it comes to counting and finding matching rotations, the approach would depend on the scope:

  • if I needed but a single puzzle in the entire game and only once, I’d hard-code it in the LB
  • for something more reusable, I’d have the knights talk to the Door Actor - it would act as the manager
  • for something more modular, where you have many levels and many doors, I’d have the door actor create the knights + levers through an EUW and bind it all dynamically

And, as you said, there might be a better solution depending on the circumstances.

Thank you so much! I’ll have a look at how these work and try to adapt the best one to my project.

Another thing I was wondering about in this system is a way to identify which lever i’m looking at. The game is in first person camera and the 4 levers will be in a small control panel. I want the player to know which lever will be used by pressing the Input key and I have a small widget that can appear on top of them. However, i dont know how to set up an efficient way to identify the lever when they are close to each other

  • create a panel with lever actors (child actor components would work well here, this way each lever can have its functionality / animations)
  • the player can line trace along the forward vector to see what they’re close to / looking at
  • when the trace hits a lever, have the panel show a widget component in screen mode at the lever location (I’d probably use an interface here)
  • look into tags in order to ID which component the trace hits and / or trace channel

This will be a bit more convoluted and the whole working system is probably beyond the scope of the AH.