Rapid Prototyping w/ New Unity Input System
Here’s a quick-and-clean example of a rapid prototype using the new Unity input system. Our goal is to create a player (cube) that can move around using the WASD keys, and fire a projectile with a cooldown. Ready, set, go…
First we need an input system:
Easy enough…
Next we need a Player Manager and a Player, with their own scripts:
And, lastly we’ll need a projectile prefab:
And now a bit of code… Let’s start with the projectile. It needs to move and destroy itself when it leaves the screen:
Next, our player needs to Move and Fire (after cooldown):
And finally, our Player Manager needs to initialize our input system and tell our Player when to Move and Fire:
And here’s all the script at a glance:
That’s it. In just a few minutes, with some very light code, we’re rockin’ a prototype!