Multiple Switches Flip/Flop Lights on/off ? Logic Puzzle
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
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:
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:
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!
asked Oct 12 '16 at 10:49 AM in Blueprint Scripting
If I understand what you are trying to do correctly, then I think you want to use flow controls. I did a quick example.
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.
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.
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!
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!
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.
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.
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 :)
answered Oct 13 '16 at 11:23 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here