2d space shooter camera

Hello,

I am trying to develop a classic 2d space shooter game.
I am wondering on how to implement the camera system.
It is clear that an orthographic camera is needed here.
What is less clear to me is how to make the camera move constantly forward and at the same time allow the player to move freely within the viewport.

Any advice?

Hello boazo,

You are on the right track assuming it needs to be a top orthographic camera. If you are attempting to make something like Galaga or Asteroids, just set up your camera in the location and field of view you wish to Render the game and lock it in place. There should not be much to this, but if you are running into issues let me know. I hope this helped.

Thanks,

Hey Andrew,

Thanks for the reply. The game I am trying to make is a little different from Asteroids and Galaga.
The difference is that the camera seems to be moving forward in a constant velocity through a predefined level - with a lot of environment beneath. At all times the player can maneuver within the view port (which is constantly moving forward) but can never go back.

Here is an example of the game IFighter 1945 that demonstrates the camera effect I am trying to implement

Thanks again for the tips,
B

Instead of moving the camera at a fixed speed to keep up with the players movement. Just create the landscape/background to pan at a certain speed that way it gives the player the illusion they are moving forward. This will give you greater control when trying to add things like power-ups that make you go faster. You can just edit the panning speed to increase or decrease indicate how fast the player is going.

Hope this helped.

yes, this is very helpful.

Just to see I got it right:

  1. The Camera itself is orthographic
  2. The scenery is panned at a constant speed that can be manipulated by other actors just for the fun of it - this creates the illusion of movement.
  3. The player cannot leave the boundaries of the camera view.

I hope I got this part right :slight_smile:

If I did get it right, how do I move the landscape/background as a single entity? (i do plan to use 3d models for building the environment). Is there a way to group the scene elements together and pan the group as a whole on every tick?

B

You are indeed on the right track!

Since you are going for the three dimensional feel you can create multiple landscapes as different levels using ‘World Composition’ and stream your levels in and/or out within the screen space.

Check out the documentation on ‘World Composition’ to see how it can be used. This will allow you to save processes for other things in your game so you aren’t rendering an entire world at runtime.

World Composition

Even though this is one way to do what you are trying, the most optimized way would be to have all the static meshes and modular pieces procedurally generate across the screen. This way nothing is rendered out of the screen space at any point to optimize your games performance.

I hope this helped get you a bit further on your way. Keep me update as to how this is going, would love to see progress.

Thanks,

Hey Andrew,

I’ll do keep you posted on my progress.
I really appreciate the quick response.

B

Hey Andrew,

After reading the procedural generation suggestion another question came up. The drawback of the first approach (designing the level in advance) is that static meshes which are partially visibile (will be rendered as a whole and the parts which are not visible will be culled out), right? I would expect the engine to completely disregard meshes which are not visible at all at a given point in time.

Do you think that the first approach is going to be a performance issue if the game is targeted for mobile devices and not only desktops?

Procedurally generating your game out of modular pieces will be more efficient and better for performance if you are targeting mobile devices. Even though you will be essentially generating your game at runtime, because you are using modular pieces instead of loading and hiding an incredibly large environment. It will be a smaller download, run more quickly, and allow for unique maps.

If you were strictly targeting the PC or Consoles, the World Composition route would be a great idea because you could build your game using large and heavily detailed environments.

It would be possible to use the World Composition for Mobile, but it probably would not be as optimized nor play as smoothly as you might like.

Goodluck!

Hey Andrew,

thanks for the patience thus far :slight_smile:
I thought to start by doing the following prototype:

  1. Setup an orthographic camera
  2. Create a PCG based level
  3. Pan the level and see that this creates the wanted effect.

How do you suggest I start with PCG? Is BP the right tool for the job or should I be using C++?
Is there any documentation / tutorial for PCG?

Thanks,
B

You are welcome. So my suggestion would be to have a good mixture of the two. That way your entire project is not incredibly dependent on one or the other, but has the ability to make the finite changes (through code), and the larger scripting changes through Blueprints.

As for documentation, there is a good bit on the forums, but official documentation is limited at the moment. That being said here is a few links to get you started.

Procedural Documentation

Procedurally Generated Dungeon

Best of luck!

Hey Andrew,

I am trying to create the pan effect and it is unclear to me how this should achieved.
I have a bunch of static mesh actors in the level and I need to change their transform in a given speed every tick.
However, this shouldn’t be performed on all actors but rather on the background objects only.
Here are my current directions:

  1. I was looking for a way to group the relevant actors and then change the group transform once every tick, but couldn’t find this in the documentation. Should I create a blueprint with the translation widget only and then place everything in it in the hierarchy? This would allow me to update the BP transform and save the need of iterating over all of the actors updating their transform.
  2. I also examined the “tag” mechanism, which would allow me to iterate over all of the actors which have this tag associated with them. However, this seems a bit inefficient IMHO. (I also saw a post in the forum which indicates that this doesn’t have good performance in UE4).

What do you think? which approach should I be taking to implement the background panning?

Thanks,
B

Hello boazo,

It seems your most valid choice would be the first one. I have not attempted this type of game in UE4, so you are going to have more experience than me as soon as you start implementing and designing. Again good luck, and let us know if you have issues or bugs during your process.

Thanks,