We can’t just rely on our ship’s laser to get the job done. This is a hostile alien fleet after all. A never-ending hostile alien fleet. Some jobs require a more… heavy handed approach.
There’s a couple things I want out of a good alternative firing method.
Particles. Sweet, beautiful, generated particles.
We’re in space, so obviously we need some stars. We could do this by finding a repeatable transparent image of stars, but we already covered that in Unity Dev: Moving Backgrounds.
Having never used a particle system before, I did my research. Much of the code output here is from: Guido Henkel’s Endless Scrolling Starfield and this is primarily my attempt at explaining what’s going on here.
At the end of it all, we’ll have three objects that are all running off the same script so that we can create a parallax effect. …
I’ve been feeling like our game environment has been a bit stale lately, which is why I switched up the background in my last article. It worked for me for maybe a day but it was still missing something. That something was movement. Motion creates emotion, as they say. So let’s get moving.
After knocking my head around on the idea of taking this repeatable nebula image I’d found, duplicating it, and then moving each one after the other as they move across the camera… well, it seemed like a whole bunch of moving parts, so to speak. …
Previously we’ve set up animations for our Powerup objects, but they’re just a set of sprites animating in a never-ending loop. That’s obviously not going to work for everything we want to animate.
For example… let’s blow up some alien ships.
And… that’s it really. So let’s take a look and see how that’s done.
Double-click your Enemy prefab to open it up in your Scene window. …
We’re going to take a short break from adding new features to our game to clean up some of the existing code. When we set up the Restart functionality with our refactor of the new Input System implementation, we made note that we created an
OnPlayerDeath() function in 3 different components so far.
In yesterday’s article, we added some UI to direct the player to press the “Enter” key or the Start button on a gamepad to restart the game when they’ve died. Wait though… our Input Actions are tied to our Player object and when we die, we destroy it! So how do we continue providing input?
Let’s begin by making an empty Game Object called “Input_Manager”. Add a coordinating C# script “InputManager” and attach it to the object. Create a new Player Input component on the object as well and set its Behaviour to “Invoke Unity Events”.
The general idea here…
I'm liking it quite a lot, James. The more I tinker with it, the more I see the potential behind it. I've got another article coming out tomorrow that refactors the original approach I took and facilitates a basic multi-Action Map approach.
These days, it’s up in the air whether players even want a user interface. A number of games include the option to completely hide the UI of games to increase immersion. That said, we’re going to create a simple display to show our player’s score and the lives they’ve got left.
Note: If you’ve been following along, you’ll notice that the background is substantially different than what I was previously using. It was done by simply swapping out the image. …
There once was a little ship that shot little lasers. The ship was happy for some time until it realized it could be… more. Welcome to powerups.
Triple Shot: Is one laser ever enough? Of course not. We need a powerup to give us 3 lasers at once for a little bit.
Speed Boost: If you move faster, you kill more alien ships. So why not?
Shield: It’s like an extra life for free! On top of that, it gives us an excuse for another cool visual.
On a quest to become a game developer. Still sometimes providing unsolicited advice about how to function in society.