x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Multiple Switches Flip/Flop Lights on/off ? Logic Puzzle

Hey everyone!

I am struggleing with an idea i had. It seems simple but i can't setup the BP correctly (or I am just missing something)

This is a simple visualization of what i want to make in my BP

alt text

I have 4 clickable switches ( I already made them work with OnClicked etc. ) Each switch can turn 1 or 2 lights on/off

For example: S1 turns L2 = ON/OFF S2 turns L2 & L1 = ON/OFF etc.

But what I am struggling with is that if I turn S2 on while S1 is still on, L2 should turn off, because S1 already turned it on. So each switch can trigger multiple light to turn On/Off. I hope you can follow me and get what I am trying to say ^^

Here is my Blueprint attempt:

alt text

I already tried using Flip Flops to trigger the ON/Off but it never worked the way i wanted. I don't know if I am on this for too long now, and can't see the obvious, or if its just harder than i thought.

The Switch Reference is just to get the Bools of each Switch when its pressed.

btw. I didn't use real Lights, these are just Static Meshes that change material when triggered, for testing purposes.

The function is simply that:

alt text

The Goal of the Puzzle is to turn all lights on by using the switches. When all lights are turned on, the puzzle is solved.

Hope someone can help!

Product Version: UE 4.12
Tags:
bplogic.png (32.8 kB)
bp01.png (370.2 kB)
bp02.png (51.7 kB)
more ▼

asked Oct 12 '16 at 10:49 AM in Blueprint Scripting

avatar image

snair_
32 5 5 6

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Hi snairFX,

If I understand what you are trying to do correctly, then I think you want to use flow controls. I did a quick example.

alt text

You can use other controls like AND and NOT and NOR for any future stuff, here is a list of them here - https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/FlowControl/

If this has solved your problem then ive got a few more recommendations. Instead of using a Tick to keep checking variables, just call an event whenever the user does something to change it. Doing it in this event driven way reduces the amount of calls to the world tick timer which will improve your games overall performance, in my experience anyway.

alt text

And the last thing you could do is if those objects you are setting the material on are all of the same type, you could use a function and just add an input value which is of that object type. More on functions here - https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Functions/

Here is what I came up with.

![alt text

I just feel that would only make one function which is very reusable, which just makes your blueprint easier to manage.

I hope that helps you, if you need any further assistance im happy to help. And thanks for providing good images, it really helps to understand what is going on!

Thanks,

Razer313

Edit: After a quick re-read I haven't 100% answered your question, but you should look at using the same flow controls as I mentioned. It will just require using different nodes to all the OR's I used. Hopefully this answer still helps you!

flowcontrol.png (172.0 kB)
flowcontrol2.png (153.6 kB)
flowcontrol3.png (31.2 kB)
flowcontrol3.png (31.2 kB)
more ▼

answered Oct 12 '16 at 12:23 PM

avatar image

Razer313
226 7 3 11

avatar image snair_ Oct 12 '16 at 06:23 PM

Thank you so much for your quick and well explained Answer !! I just edited my whole BP and it seems to work now! Thx ! I am only using 1 function to update the lights like you did, as well as the OR/AND nodes to check the switches.

And thank you for the tipps on the EventTick, i wasn't quite sure what Event to use there. I will work on that too.

My blueprint is a total mess now. As soon as I have cleaned up the code and everything is still working, I will post my solution with screenshots!

Thanks again for the help!

(comments are locked)
10|2000 characters needed characters left

So after working on it for a while I was pretty happy with my result. A combination of AND/OR nodes worked great. It's not 100% what i had on paper, but I realised that this "Logic Puzzle" I wanted to use as a mini game inside another game, has to be dynamic, so each time the player has to solve it, the switches have to be assigned to different lights. Without setting the switches randomly each time the game starts, it would be totally boring.

alt text

This is how I made it work with your help. But I am working on setting the switches randomly right now. So I am changing things as we speak.

alt text

The S#Values are 3 random integers, one for every light. Once a switch is pressed, it will call a function which is a SwitchOnInteger that includes all my lights. So everytime you start the game, the switches will control different lights. And it works just fine aswell!

Thank you again for your help! My blueprint looks way better now and I'm progressing faster :)

update1.png (186.0 kB)
update2.png (266.3 kB)
more ▼

answered Oct 13 '16 at 11:23 AM

avatar image

snair_
32 5 5 6

avatar image Razer313 Oct 13 '16 at 12:19 PM

Thats fantastic, glad I could give you a push in the right direction but well done to you for being able to implement a working solution so quickly all by yourself! And thanks for providing your solution so that if other people stumble upon this post in the future it will help them out!

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question