Cheat it and beat it…

Andrea Zilio
2 min readMay 29, 2021

Today we will create a little cheat for the space shooter game.

Objective: Whenever a powerup has spawned and the player hits “C”, the powerup will move right to the player. It’s for lazy players to discover.

My objective is to keep it simple.

In the Player Script we add a boolean variable _cheatActive

and then the basic logic to the update method:

Then in the script Powerup script we add three variables:

The regular powerup speed is slow. A faster _cheatSpeed variable stores the speed for this feature. The _playerPos will store the position of the player. And the _player variable is needed to check for the status of _cheatActive.

Then it is time to grab the player.

And now all we need is to check in the update method whether _cheatActive is active and then get the player position and move the powerup to the player.

It is simple, and it works!

Time to beat those enemies with all the powerups :).

--

--

Andrea Zilio

Passionate Game Developer and Learning Expert. I love to create games and interactive experiences using Unity, Articulate, C#, JavaScript, PHP, HTML, CSS.