Tuesday, August 4, 2026

Menu Tutorial: Cycling Blades

    I hate building Main Menus for my games. I always spend a ton of time working on game play and then months in forget that I need to make a way for players to actually access things. So, I've decided to make a flexible, and reusable menu template. Here goes the first piece, what I am calling "Blade Cycling."

    Let's start with some basics. We have a camera with a canvas attached, and set to "Scale with Screen Size" just in case I am working on a project with a different aspect ratio. That'll keep everything in the right place in the scaled canvas.

    Onto the Visual Script bits.

    This is the script for the "Start" button in the bottom middle. We have a scene variable, and Int called "Active_Blade" that keeps track of which blade on the AoT list we want to set active after the cycle. There is also an object variable attached to the Start button that contains the target blade number. In this case, 1.

    After we set the Active_Blade variable to 1, we are going to message the Controller (a script stored in an empty that controls everything) using a Custom Event Trigger block.


     And here is what it looks like inside the Controller. The keyword "Cycles" triggers the Custom Event, shooting us into a For Each Loop (everything in red) which is hooked up to the Menu_Blades (on the left) AoT. This will fire the Body node of the Loop once for every entry in the Menu_Blades AoT list. In this very early case, just twice, and since it is attached to a Set Active block, it will set each item on the AoT list as inactive.

    This leaves us with a completely blank slate.

    Now comes the Exit node of the For Each block (everything in lighter green) and actually using those earlier variables. We are pulling an item (List - Get Item) from the Menu_Blades AoT list, and specifically the Active_Blades item, which should be 1, but I forgot when I took the picture. (AoT lists start at 0. So, if we are trying to set the second item on the list as active, we would need Active_Blade to be set to 1) Then we feed that into a Set Active block toggled to active instead of inactive, like how it was used in the clearing loop.

TLDR: The script on the Start button tells the Controller what blade should be shown at the end, and then tells it to cycle. The Controller clears everything, and then goes back and sets the specific blade requested by the Start button as active.

    Long walk for a short drink of water, but hopefully I'll show you later how these scripts can be flexible and reused.

    Later.