Home>

I'm making a game with Unity.
Move the characters on the screen with the alphabet key buttons,
I want to select a menu button with the arrow keys.

Currently in the script attached to the character
By the Input.GetKey method in Update,
I succeeded in moving the character.
However, at the same time as moving the character with the alphabet key,
Also select the menu button beside
For some reason, I am troubled because the same button will move without permission.

I would like to have different buttons work separately.

Applicable source code

The script given to the character is
void Update()
{

if (Input.GetKey(KeyCode.W))
{
transform.Translate(0, 4.5f * Time.deltaTime, 0);
}

if (Input.GetKey(KeyCode.S))
{
transform.Translate(0, -4.5f * Time.deltaTime, 0);
}
...

Is like that

What I tried

If i deactivate a button, it won't be selectable
I know,
You cannot do what I want with that method.
(I want to select menus and commands while moving characters)
I'm in trouble because it doesn't come out even after checking.

It may be difficult to convey, but thank you.

  • Answer # 1

    Present in Unity Button component settingsNavigationThe property is probablyAutomaticIt seems that it has become soNonePlease try.
    I think this will remove the focus shift in WASD