≡ Menu

RunJumpShoot – A Free Canabalt-style Jump Start for Unity

This weekend was the latest 48 hours MiniLD game development competition (link here). Unfortunately I can’t devote 48 hours this weekend to making a game, but I decided I definitely wanted to make SOMETHING. I’ve been playing a lot of Monster Dash lately on my iPhone, and I’ve always been a big Canabalt fan, so why not make something Monster Dash/Canabalt-like for Unity?

I grabbed some assets from the 2D and 3D platform tutorials that Unity provide, added a bunch of code and stuff, and here’s what I came up with. Spacebar jumps, Enter shoots – simple!

Click the image below to play it in your browser:

—> Download the full Unity project by clicking here.

The Basics / Introduction

As discussed briefly above, RunJumpShoot is a Canabalt-style jump start for Unity. It’s a basic implementation of the genre, and should be a great starting point for anyone interested in making a game in this style. Here’s a quick rundown of what’s included:

Running, Jumping, and Shooting
Basic controls include running (automatic), jumping (spacebar), and shooting (enter). As you move through the level, your character will run faster and faster and faster.

Random Level Generation
Levels in RunJumpShoot are generated randomly, including monster and health pickup placement. You should never end up with an impossible jump.

Power-Ups
Maybe that should be singular, since there’s only one power-up: a health pickup. It should be a great template for adding more power-ups moving forward. The game also tracks health, and if you take too much damage then it’s game over.

Monsters
Again, there’s only one monster included – a robot. It’s a pretty dumb robot also, not one of the super smart robots/AIs that can battle champions on Jeopardy. These guys just kind of spawn in randomly and move left or right whenever the player gets close. Nothing super advanced, but not light years behind what’s in Monster Dash – and that game is a blast!

Implementation Notes

If you take a look at the Unity project included, you’ll notice a few different folders. The assets that came directly from one of the Unity tutorials are in the appropriately labeled folders (2D Gameplay Tutorial, 3D Gameplay Tutorial) – these are assets that I didn’t change, they’re just copied straight from the tutorial. Most of the files outside of those folders were added by me.

Just about all of the scripts that I wrote are in the Scripts\ folder. You’ll notice a few .js files in there, those are copied over from the Unity tutorials – all of the new files that I added are in C#. You might wonder why PlatformerController.js is in Standard Assets\ instead of Scripts\. Well, I access that component from ProgressController.cs, and apparently with Unity there’s some weirdness with compile order when trying to access a JavaScript component from a C# one. Gotcha! Check out this thread for more info.

Most of the other included scripts should be fairly straightforward. If you have any specific questions, feel free to drop me a message!

Future Work

Here’s a list of some things you could if you want to turn this into a sweet game:

  • Replace everything in here with sweet graphics. Add sound/effects.
  • Fix the lighting, I have no idea what I’m doing when it comes to this kind of thing.
  • Add different types of enemies.
  • Add some sweet weapons/power-ups.
  • Extend the random level generation algorithm. The one in there now is pretty decent, but there’s always room for improvement. Maybe you could try some different platform slopes or something?
  • Add some sort of level progression.
  • High scores?
  • Some other funky gimmick to differentiate your game from the basic formula!

What Can I Use This For?

Feel free to use any of the code that I wrote for any project you want – commercial or personal. The only thing I ask is that you drop me a line and let me know if you end up using it for something. Good luck!

Also if you’re interested, here’s the discussion thread I posted on the Unity forums:

http://forum.unity3d.com/threads/75017-RunJumpShoot-%96-A-Free-Canabalt-style-Jump-Start…-Source-included!?p=480197#post480197

{ 14 comments… add one }

  • Ash February 3, 2011, 9:40 am

    Hi, first off, I love this starter pack and the others you have produced.
    I’m currently learning the ins and outs of Unity at the moment and your packs are a great help. I was just wondering if you could point me in the direction for making a scrolling background to go with the RunJumpShoot. Almost like a parallax background that moves more slower than the foreground. I don’t expect you to write it for me, just a pointer in the right direction would be huge help.
    Thanks again for the packs

    Ash

  • Steve February 3, 2011, 1:00 pm

    Hi Ash, there are a few different approaches you can use.

    One idea is to add one or more planes in the back of the scene that has your background texture(s) on it, and then parent these to the camera (probably dropping off the y movement) so that they follow as the camera moves. You could write a simple script to move these at speeds that are slightly different than the camera to get the parallax effect.

    Another option is to use one plane with animated textures:

    http://answers.unity3d.com/questions/12711/making-textures-scroll-animate-textures

    Hopefully this helps – let me know if you have any other questions!

  • Ash February 3, 2011, 5:37 pm

    Ah thank you very much, that first idea makes perfect sense, not sure why my brain didn’t think about that; too many late nights I think haha.

    Anyway, thanks again and keep up the great work, you’re a valuable asset to the Unity community

  • math games February 8, 2011, 9:11 pm

    thanks

  • Felix March 13, 2011, 6:59 pm

    This is very useful for a beginner like me Steve, Thanks.
    Right now I’m trying to make a level based game out of this,
    how do I change it so that I can disable the random terrain and design my own levels?

  • Leon March 23, 2011, 8:23 pm

    You’re awesome! Thank you for this.

  • Mons July 22, 2011, 10:00 am

    Thx for the this awesome source, I am a beginner currently was learning unity in javascript was wondering is there a javascript version for this kind level generator? and thx again for the sharing is really aweomse : )

    • Steve July 22, 2011, 1:36 pm

      Unfortunately it’s not available in javascript. It should be pretty easy to port over if you’re interested in the project, probably a good learning experience =)

  • Guilherme Killingsworth August 9, 2011, 5:24 pm

    Great work man,i have a question,what exact script or code line make the character automatic move ?

    • Steve August 9, 2011, 10:56 pm

      Hey man, check out the variable alwaysMoveRight in PlatformerController.js. Let me know if you have any other questions!

  • Steven April 21, 2012, 6:35 am

    I never comment on these posts, but man this is perfect. this is a great starting point for me for what i want to do. thanks so much man

    • Steve April 21, 2012, 12:44 pm

      Glad it helped, good luck with your game!

  • Just Some Internet Guy You Dont Know September 13, 2012, 12:07 pm

    Looks good but being a beginner it might be out of my range right now to do anything with it. Had an idea like this for a while but no way to implement it with my limited C# and Unityscript skills. Great to have a jumpstart though.

  • Just Some Internet Guy You Dont Know September 14, 2012, 12:43 am

    I’m still learning so this is beyond my current skills but looks like a great learning tool if I do decide to go to C. Had an idea like this in my head but no way to implement it yet. This is a great jumpstart. Thanks.

Leave a Comment