Light Puzzle help

I’m very new and to unreal and I’m still learning and I’m creating a a light puzzle that is based on this video UE4 tutorial: How to make a simple puzzle game but I do not know to check if all the lights are lit up and this is the closest I got but it does not work.


The code above is the main code for the tiles


the code above is suppose to check if all the tiles are lit up print hello but its not working


and this is the light code

On the second screenshots how is your array populated? From what I can understand of your blueprint it seems to only contains the adjacent tiles, and not all tiles. You should look at GetAllActorOfClass to check all tiles in the level. Also, I would test the validity of the last ForEachloop element to know if a light is lit or not, you should instead set a separate boolean to true if there is a light lit, and then after breaking the loop you should check is this boolean is true or false.

1 Like

in the tile game when you step on a tile the other tiles light up so that is how it gets populated.
for the getallactors I’m supposed to use it in the TileCheck event right?
and did I check for the validity properly?

On the second screenshots how is your array populated? From what I can understand of your blueprint it seems to only contains the adjacent tiles, and not all tiles. You should look at GetAllActorOfClass to check all tiles in the level. Also, I would test the validity of the last ForEachloop element to know if a light is lit or not, you should instead set a separate boolean to true if there is a light lit, and then after breaking the loop you should check is this boolean is true or false.

There is a more “correct” way to create the mini game:

  1. Create the tile like in the video; the collision box + static mesh. Set the static mesh collision to no collision and the box collision as the root component. The component hierarchy should look like this:
    image

  2. This is the Event Graph of the tile blueprint:

  3. The Toggle function:

  4. Place them in the level and reference the neighbors accordingly:

And thats it…
Tiles


If you are interested once you have it working with the steps above I can show you how to implement a win condition when all are green.

Feel free to ask about anything you need help with.

3 Likes

Thanks I got it working with the steps you provided and I very interested to see the win condition that would be amazing

Awesome!

  1. The tile just needs 1 more node:

    More info about dispatchers here.
  2. Create a new actor class and place it in the level. Give it a static mesh component just so we can see it and debug.
  3. Create an array variable same type as the tile class and set it to instance editable. Add the tiles we it want to observe same way as it was done with the neighbor tiles:
    image
  4. Now in the new actor, in Begin Play we bind to the dispatcher:

    And from the Event pin drag and search for Custom Node:
  5. Next check each tile for a false value, if one is found break the loop and do nothing:
  6. Finally add what to do when no false value were found:

Now just play:
TilesWin


In time I’m sure you’ll eventually find ways to make the program do some of these steps for you. There are also more advance ways to create this that are less tedious.

Hope it helps.

3 Likes

(post deleted by author)

(post deleted by author)

Thank you for your help I appreciate it a lot!

1 Like