2D game with depth?

Hey,

Is it possible to create a game using the new 2D tools that also has an element of depth as well as physics or would I have to use 3D?

1514242--86156--$setup.png

So in the attached image the first 2 characters are walking on the same path, and the character at 1 is moving down a slope on the path.

I tried to play around with a simple example, but obviously orthographic projection isn’t suited for this kind of thing and perspective doesn’t fit right either as I don’t want to affect the scale.

I think maybe I’m trying force square pegs in round holes but someone might have an idea about this.

I guess a very basic explanation would be a perspective similar to Streets of Rage

Thanks

Orthographic projection would work fine. It looks like it would be simplest to use 3D, though you can still use sprites, just not the 2D physics engine.

–Eric

Why can he not use 2D physics to do this? Because of the Gravity?

That darkest brown part (the ground and below) would have a collider at the top edge.
Then going Up and Down, moves the character on the Y axis. Up to the collider at the bottom edge of the blue.
I don’t really get it. Couldn’t you just make this like the game Streets of Rage did? They used 2D colliders to block movement all the same.

Wouldn’t this just be a 2D game where instead of jumping, Up / Down moves the character on the Y axis?
Is there a need for 2D physics?

2D physics is on the X/Y plane only. The illustration has depth to the environment; it’s a relatively narrow strip, but nevertheless 3D. It would be simple enough to just use 3D physics, no reason not to since it would make things easier, and no particular reason to try hacking in 2D physics.

–Eric

Well he can use Physx and a set of 3D colliders with the 2D engine. This would work fine. He’d need to create a range between 0 and the far edge and divide it by that amount to return a z coordinate between 0 and 1. Call it scaleZ.

Then for the sprite system you set the scale to = 1.0f-scaleZ*0.5f or such (whatever amount until it looks right for your graphics). Should work perfectly fine. You’d probably want to plug this number into the sorting for the sprites too.

It’s actually a lot simpler than that, just move the sprites around like normal objects in 3D space, since that’s exactly what they are. The only thing “really” 2D about the new 2D stuff is the physics engine.

–Eric

Thanks for all the ideas. Sorry it’s taken me so long to reply. I posted late last night and only just got back from work. I would require physics as not all the gameObjects would be controlled by a person, some would be AI and they would need to be able to go up and down stairs for instance, but some could obviously appear further from the camera on the stairs (as if they were walking 2 abreast)

Then use the above advice. It’s valid. Just use 3D physics instead of 2D physics.

I’m guessing I would need to change the angle of the camera to show the depth of the flat part of the level? Would I just set the whole scene up as 3D originally and then just use my sprites and fix the camera angle? Sorry if these questions seem basic.

So I sort of have this working, in that I have a cube where my gameobjects are on the z-axis and gravity is working as expected. However I have a sprite that acts as the background to my level. As I have adjusted my camera’s Y position and x-rotation the background doesn’t appear where it should. The top gets cutoff and I don’t see the bottom. Which I can understand based on where my camera is. But how would I get round this? Should I have 2 cameras and have 1 camera render the 3D floor and entities and ignore everything else and then have another render the rest of the 2d level? Or is there some math I can use to position the camera correctly? e.g if my camera is rotated by 15 on the x-axis and moved to a Y-POS of 2 with a size of 5. Can I somehow calculate how I should position my background?