Download

Help with a puzzle mechanic.

Hi All,

I am a total noob. Been working with the engine for maybe 6 months to a year, but retention and comprehension on making tutorials applicable to my specific projects has proved more than difficult.
so if i sound like an idiot… sorry.

Anyways,
I have a set of 4 torches, what i would like to be able to accomplish is lighting the torches. When all 4 of the torches are lit (in any order) a gate opens allowing you into the next area.
Kinda feel like there is a really simple solution to this.
I sort of figured out how to make the fire and a pointlight spawn on button press but right now its in the level blueprint,
But im not too sure how to go about connecting the blueprint of the torches, and make it open the gate.

Thanks,

Austin

Hi,

I think you should set a Boolean that checks if a certain torch is on or off. Where you implement your ‘turning the torch on/off’ logic, set a Boolean to True for each torch you turned on (eg. isTorch1On, isTorch2On etc.). At your door/gate opening logic, just use an AND Gate (I think the node’s name is AND Boolean). You plug your ‘isTorchOn’ booleans into the AND Gate and it will only return true if all of the plugged in values are true. You check the output, and if it is true, the door/gate opens.

I hope I could help a bit.

Awesome!
Question though, would the logic be done inside the level blueprint, or would i individually make torch blueprints then connect them somehow?
I genuinely hope that you didn’t explain that previously, and that I’m not wasting your time.

If you have anything you’ve done like this previously an image of how it might work would be insanely helpful?

It depends on your preferences. Generally people don’t like to handle too much stuff in the Level Blueprint, but for smaller projects I think it is perfectly fine to use. On the other hand, if this ‘torch needs to be turned on to open gate’ system is something you use several times, it is definitely a good idea to make it in a separate Blueprint.

Unfortunately, I do not have anything similar right now, but if you really can’t get it to work I can make a simple example setup for you tomorrow.

using the level blueprint only to script games in ue4 is like using a bugatti to get the mail.

You should take a look at event dispatchers

I tried to get it to work but now i cant seem to understand why it wont toggle the visibility on the bp, so far i deleted the variables and tried to tackle the visibility.
I’m including some pics of the BP i have started, so hopefully you can see where im headed and maybe help from there.
I would feel bad for you to have to make an example.

Agree on the event dispatchers, disagree on the bugatti. If I had a bugatti Veyron then I would be using it to get mail all the time! :smiley:

I feel so bad now, how do I open the images? :smiley: I can only see them in thumbnail size, and well, cant really see anything :smiley:

right click ->open in new tab

Let me try something different with it.

b5bc16247e600de733fe98444dc1826c47c7cf22.jpeg77589fa544dab193b2ef78a587f178e5bce565a0.jpeg6f26b875d7f06783965e6e73e0c441e1ad2ed7fe.jpeg

I will definitely try the event dispatchers. And yeah I’m with you, I might even deliver other peoples mail just to drive that thing all the time!

So i added this in, so now when i press the ‘E’ key the torch and the pointlights come on.
354c239a280682eb0da7b7d84cc4aaaa774b7b0b.jpeg

I started the boolean logic but im honestly not too sure where to start as far as what to do next.
84decf6cc69e2a4d70f2a4429a3ac2e504812550.jpeg

Hi,

You are getting there! So if I didn’t misunderstand you, the torch light up mechanism is working right? However I am a bit confused about the setup. I hope you only created one blueprint with the torch light up system not one for each torch :smiley: What I can see now, that in the last picture you attached you are checking the value of the boolean not setting it. Use a set node there, and set your boolean to true (because the torch is now turned on). You will want to check all your booleans at the gate, to see if all of them is true.

For the gate opening mechanism I would use the Level Blueprint, but others might disagree on this with me. Give me some time, I’ll try and find you some proper explanation about how you could implement the gate opening logic, if I can’t find I will try and help you myself, but I am no expert, so take everything I say with consideration.

[EDIT]

After some research, I agree with the solution that was offered by the guys above me (with much more experience), you should use Event Dispatchers. Have a look at the link that SaxonRah sent, it should get you started on how to use them.

Hey there!
I apologize for taking so long to reply, Work and personal matters got in the way.
Yes it is only one torch light blueprint system. So ill set the node and also set it to true.
Ill check out the event dispatchers. They seem pretty difficult to understand but I’ll figure it out.
I genuinely appreciate all of the help. Hopefully you learned a little bit too, and can apply it to your game as well,
A good puzzle mechanic is always okay.

[Edit]
This might be a really dumb question but would the event dispatcher go inside the gate/door blueprint and then be called and activated inside the torch blueprint?
Also, does the torch need to talk to the gate? Or does the Gate need to talk to the torch?
Plus this link: Event Dispatchers explained - Finally ! - Blueprint Visual Scripting - Unreal Engine Forums
It was extremely helpful, but I’m curious how to apply this to the puzzle. Not why it is applicable or anything just how it would be done.
Again, i can post pictures of what have so far, but not too sure if that would help.

[UPDATE] Puzzle Mechanic. More about Event Dispatchers.

So far here is where I have gotten on the Event dispatchers for the puzzle.
The documentation while helpful is so vague. And the info i do find on them i have a hard time applying their logic to the situation i am wanting to use them for.
If anyone knows that i am headed in the correct direction or not please let me know.

So here is where i changed the ‘Branch’ with the ‘get’ on the bool to ‘set’. So it should be set to “is on?”
If i understand the code correctly then it should mean:
That when I walk into the collision of the torch, i have the ability to push a button.
When i push the allotted button then it turns the torch on.
The bool says “Hey, I am on fire!” allowing us to use event dispatchers to let it talk to another BP.
Also this allows us to set up the logic for the Event Dispatcher?

Here is where some confusion lies:
Right here I Assigned the Event “Gate Dispatcher” to the boolean “Is on?”
If I understood correctly. Since i set the boolean above it should mean that the event dispatcher calls on the event when the torch “is on?”
b8f712bf8676c6ad153e39a42e60eb5112574f5b.jpeg

Or should I bind this event to this blueprint and have it called from the gate?
And is this the way to set up the logic for the Event Dispatcher?
Is everything I’ve done inside this blueprint right?

So here is where i got super confused.
Do i need more than one dispatcher and really where does it need to be assigned from?
For instance, if it only needs one in order for this code to work, then would i need the dispatcher to be on the gate or the torch?
So I made 2 and tried to connect them, it doesnt show a compiler error, but then again the gate doesnt do anything either.

Only showing this in the event that it messes up the gates movement.
So that hopefully this is what is messing it up and i got the event dispatcher correct.
Probably not but i want you to see what everything is connected to so you know what might be causing this not to work. (If you dont already)

Last but not least here is a picture of my timeline that i added into the gates blueprint.
I don’t completely understand timelines. So maybe if you’re a person who says:
“Hey, I might not understand event dispatchers, but i do understand timelines and man this guy screwed up”
then maybe you could send me in the right direction.
It is a vector track, supposedly sending the gate down 50 units per keyframe. Not too sure.
93a312dbd269b2996df2fd86ffcbc46d914282e3.jpeg

So now my last question(hopefully) is this:
On the 3rd and 4th picture is shows the scripting that is for the gate.
When done correctly should it mean that “Once the torches are lit, then call the timeline to open the gate?”
I may have completely over thought this. Some more answers and advice would be so much appreciated.

Thanks,
Austin

You can make 1 blueprint for each task. Analysing it its pretty much 3 tasks.

  • Torch
  • Door
  • Puzzle

So make the torchs do there thing normally.
Make the door do its thing normally.
The puzzle parte will handle the test and the task.

So you have your torchs in place, each with there own name and reference which will be used in the puzzle BP to make the test. Those all torchs are lit? if so the puzzle BP will open the door. simple as that.

Listen you really will want not to use level blueprint unless you really know what your doing.

Use always BP class, its a clean way to do thing. Dont get messed up. And after you make it you can replicate it as much as you want, the job is done just once amd you have lot more flexibility and reusability as possible.
Like in this example i gave, 1 BP for each task. So lets say you decide you want 10 torchs next room to be beat to the next. you dont have to create everything again, just get the torchs place them, place the door, place the puzzle.

The TIP i gave you is to look for tutorial about how to use construction script, to make things easier.
Lets say you have your puzzle BP, but instead of going to the graph editor every time you need to teste new objetc(the number of torchs) you must create in constrution script a way to set this option in the details of your blueprint(component) so all you have to do is place the torchs, place the puzzle and go to the puzzle details and assing there the number of the torchs will be tested and which ones.

Remember it seems so complicated to do it so, but once done no more wworries and you will be able to reuse same BP as manytime as needed.

IGNORE THE FAR RIGHT SIDE OF THE PICTURES UNTIL THE LAST 3 OR IT WILL THROW YOU OFF.
I have a second monitor and couldn’t figure out how to get it to go away on paint.
Right Click and open image in new tab to View Pictures

Okay so I never thought something so simple would give me so much trouble, but that being said it was SO simple. So simple that i almost gave up game development in general because of how frustrated i was that i didnt understand what was going on.
Now, that being said Thank you guys so much for helping because if it wasn’t for you guys then i wouldn’t have learned this and that was the whole point of this project in the first place.
I’m going to post pictures of how I did it so that other people can see, what is going on.
It is just a simple lever system, super simple. No bp interfaces needed, no event dispatchers. Super simple.

I tried to make the pictures as simple as possible so that if someone(like myself) doesn’t have some basic knowledge they could understand it and hopefully make it work.
Also a huge thanks to @Kontur and @Jotajin for the help, i know i already said thanks but I mean it.

I did try the 3 bp but i ran into the issue where i had no idea what or how to code the puzzle part. I wasn’t sure what i should put where or why i would be putting it there.
But as far as using the bp class i def took your advice and made sure that i stayed away from the level blueprint. And made the number of torches visible and exposed on spawn so that they were editable and i was able to
add as many of the torches as i needed. Which was great!