Dogfooding: PeaNinjas part 1
I decided to make a very small game with Unity. Coincidentally, Danc of Lost Garden fame just announced a small game design challenge called “Play With Your Peas“. It comes with a set of cute graphics and a ready-to-be-implemented game design. What more could I want?
So it’s a small very small 2D game without any next-gen bells and whistles. It can probably be done casually on the side, by allocating an hour here and there. We’ll see how it goes. Hey, I never actually done any game in Unity, I only make or break some underlying parts…
Of course, first I start with no game, just imported graphics. Hey look, I can do sprites!
Then cook up some base things: define the game grid, throw in some basic user interface on the right hand side, and make it actually do something. This wasn’t so hard; that already gets me an almost working level building functionality. It does not have fancy block building delay or block deletion yet; that will come later.
Next come basic physics. Danc’s design calls for simple arcade-like physics (things moving at constant speeds, bouncing off at equal angles, and so on), but in Unity I have a fully fledged physics engine just waiting to be used. Let’s use that.
The design has sloped ramp pieces, which are hard to approximate using any primitive colliders, so instead I’ll use convex mesh colliders for them. Now, on this machine I only have Blender, which I totally don’t know how to use; and I was too lazy to go to PC and use 3ds Max there. What a coder does? Of course, just type in the mesh file in ASCII FBX format. Excerpt:
; scaled 2x in Z, by 0.85 in Y
Vertices: -0.5,-0.425,-1.0, 0.5,-0.425,-1.0, -0.5,-0.425,1.0, 0.5,-0.425,1.0, -0.5,0.425,-1.0, -0.5,0.425,1.0
PolygonVertexIndex: 0,1,-3,2,1,-4,1,0,-5,2,3,-6,0,2,-5,2,5,-5,3,1,-5,5,3,-5
It’s a left ramp mesh! So much for fancy asset auto-importing functionality, when you don’t know how to use those 3D apps :)
![]()
After a while I’ve got peas being controlled by physics, colliding with level and so on. Physics is very bad for productivity, as I ended up just playing around with pea-stacks!
So far there’s no game yet… Next up: implement some AI for the peas, so they can wander around, climb the walls, fall down and bounce around. I guess that will be more work and less playing around… We’ll see.
looking good Aras. I know the art was created by Lost Eden. But it is looking good setup in Unity I must say. Some questions if i may. How did you set up the grid system? I noticed you have a red grid in the background, was this done with OpenGL calls? Also how did you display the sprites on the 3d objects? I noticed you’re using a “sprite” shader… is that something you are able to share?
Cheers.
The grid is done via Gizmos.DrawLine calls from inside OnDrawGizmos.
The sprites are quad mesh with the texture applied. They are always aligned to be facing camera, so it looks 2D from the front. The rigid bodies have a configurable joint attached that keeps them at Z=0 all the time. I think most of those concepts are explained in a 2D gameplay tutorial on Unity website.
I could have used Transparent/VertexLit shader, by using emissive color and black colors for diffuse/specular so that the sprites are not affected by lighting. The shader I uses is just simplified Transparent/VertexLit one, without any extra stuff I need.
I tried doing what you said on the forums…. but i just cant get it working. Any chance you will release the project folder so we can see how you did it.