Chandler Lane

Coroutines give us the power to easily implement logic for waiting a certain amount of time. This is perfect for a cool down system. Let’s take a look.

First we need a control variable to handle when we can and can’t fire.

We also need a variable to determine…

--

--

As game developers, we can give life and we can take it away. Unity lets us play god, easily.

The Instantiate() method that unity provides, gives us excellent control over bringing objects into existence. In this example, I am specifying what I want instantiated(laserPrefab), where exactly I want it(muzzleLocation.position), and the rotation it will have once instantiated( quaternion.identity). I could also add one more argument I wanted the instantiated object to have a parent.

The instantiant method also returns the game object reference that was just created.

--

--

We’re going to be using the Old Input system for this. I find it convenient for quick prototyping.

first, We’re going to start out by serializing a speed variable that we can adjust from the editor.

Easy enough. Now, for the meat and potatoes. We need to access the vertical and horizontal input so we can use that in our movement calculations.

--

--