How to use arrow keys to select buttons?

I think the Undertale button selection system is really cool, so I was wondering if it was possible to do the same thing: Using arrow keys to select buttons.

1 Like

It is, you just have to map out the frames and move around from there. Here’s how I’d do it:

I have 3 frames set up.

  • The left frame (Frame1) has its NextSelectionRight property set to Frame2.
  • The middle frame (Frame2) has its NextSelectionLeft property set to Frame1. NextSelectionRight is set to Frame3.
  • The right frame (Frame3) has its NextSelectionLeft propert set to Frame2.

In code, create a CurrentFrame variable with a default frame. Then, hook up some input events to any keys you want to move around with. For example, WASD.

Lets say CurrentFrame = Frame1 for this example. Using the UI layout in the image above.

If “W” is pressed, check if CurrentFrame is pointing to another object through its NextSelectionUp property. If it is, set that object as the current Frame (You can create an effect to visual the transition).
In this example, there’s only one NextSelection property set. It’s the NextSelectionRight (Which is the middle frame (Frame2)).

Pressing “D” will set the CurrentFrame variable to Frame1.NextSelectionRight, since it’s valid. Then Frame2 (Middle frame) becomes the new CurrentFrame (selected frame).

6 Likes