Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

After modifying your edit a bit. It achieves what I want. Your original edit has the error of null value (somehow). I'll just share my edit.

if (Input.isPressed('left') && $gameSwitches.value(n)) dx -= 1;
if (Input.isPressed('right') && $gameSwitches.value(n)) dx += 1;
if (Input.isPressed('up') && $gameSwitches.value(n)) dy -= 1;
if (Input.isPressed('down')&& $gameSwitches.value(n)) dy += 1;

Not exactly a pretty code, but it works. Thanks for your help.

(2 edits)

Oh, most likely it gets called before the game state is initialised. I updated it with a more reliable fix for that.

You may also want to check that the current scene isn’t a menu, if the player can open one while the Switch is ON.

Edit: Typos.

(+1)
You may also want to check for whether that the current scene isn’t a menu, if the player can open one while the Switch is ON.

Yea I noticed that. Thanks for your help!