Best way to initiate waves of enemies... 2D Shooter

Hello!

I am doing a side scrolling shoot 'em up. It really just appears to be scrolling and only limited moving pieces go past the camera, enemies, rocks, the background doesn’t move much. I am not sure how to really create the waves of enemies. Should I use a co-routine for encounter 1, then another for 2, and so on… Should I have a scrolling world where enemies activate when entering camera? Should I use associated trigger colliders? If you guys are staggering enemies and don’t want their movement to start until player is near, otherwise they’re way off for timing and placement, what are some of the best ways you’ve completed this?

I created a big map where enemies just target player. When you scroll to the end of the map the enemies will need to be very far, have higher speed, and be vertically way far so that when the player catches up to that part of screen space it still appears to kind of be attacking, otherwise it may not even be in camera or might hit player super quickly.

I am sorry I don’t have more information. I could provide some videos and screen caps of what I have done, but I figured this is more of a discussion of possible solutions. Would any screen captures, code, or videos help?

I value each and every response! Even the trolls!

Here’s a video. My artist did the UI, and he did not use a canvas and image element, instead he used it as a sprite with a sprite renderer. This seems improper for UI…

I would keep the camera in place and update the background so it appears the player is moving at all times, precache all of my enemies I plan to use in a pool so that I can just activate ones when I’m ready for them and then use a timer or other means to figure out when and where to place the enemies outside of camera view to begin participating in the game.

1 Like

hi. I too am making a side-scrolling shootem-up. I dont think there is really a “correct” answer to this, it just comes down to what works for you in terms of providing the control / performance / workflow speed you require. Things to consider:

Object pooling
Fixed vs random spawning. Do your levels have a start and end or are they endless?
Movement of enemies / paths / how to create variation with a fast workflow for you / your designer
Potential interactions between enemies and environment, e.g. turrets attached to scenery, enemies need to rise up a gap in the scenery
Capture of stats associated with enemies e.g. “whole wave has been destroyed”
Persistent / special case enemies e.g. bosses

In my case the level itself has a specific path through a 3D environment so the spawning of enemies / other game actions are tied to the position on this. Spawn actions vary in form but are triggered (activated) by the path reaching a certain point. Most of the movement in the game is tied to the concept of a “viewport”, so although this moves in 3D through an environment the player and enemies etc move in this viewport.

Good luck with your project!

1 Like

Thanks friend!

May I ask how would you initiate the timer? I know we can explicitly utilize time in Invoke to instantiate pre-fabs, this is not pooling as you mentioned, but a sort of start…

There are coroutines which explicitly utilize time.

I could ++ interate a variable on the fixedupdate method and count steps, but I’ve found that sometimes checks get skipped on some updates so targeting one value may not be successful. But if you can do something like >= then stepping per fixed update is trackable, from my experience…

I appreciate the advice and I am looking into getting that into an example. I plan on testing as much as I can!

Oh indeed. I am experimenting with both full fixed spawning, hybrid, and full random. Survival modes as well as campaigns, basically endless vs. linear with end. I don’t exactly know what will stick to the end game as far as game modes and spawn types, the testing will provide more ideas! Triggered by the path, but like by an object tracking player Transform or by colliding with an actual trigger? Or via something else strange like when in camera view monobehavior or gameobject inherited methods? Thanks for the reply!

Hi! the main path of my game is based on a third party asset called PathMagic which essentially has a little component which moves a point along a spline at position zero to one. I tie into that. The main camera for the game and the viewport are attached and moving on this spline:

Broadly my approach is as follows:

  1. Make a list of “spawn actions”, each of which is associated with a position on the spline, e.g:

0.1 - spawn enemy type 1
0.2 - spawn enemy type 2
0.25 - spawn turrents

  1. keep a counter of which of these actions have been executed.

  2. on each frame check to see if any new actions are needed, and if so run them.

I store the actions themselves serialized as JSON for (relatively) easy editing, and use a tool called fullserializer to convert from json to in-memory classes

With hindsight, I am not sure if my approach is optimal from a workflow perspective as a fair amount of “tweaking” is needed to get the enemy waves to line up as I want against the background.