Walker Boys Studio – Unity Training – Lab 4 (Super Mario Bros)

This is my 4th post related to Unity 3D and Walker Boys Studio’s free tutorials. I decided to start learning Unity and follow with the amazing tutorials created by them.

You can read more about this fourth lab by following this link: Walker Boys Studio – Unity Training – Lab 4.

If you want to play my “Super Mario Bros” clone feel free to click on the image below

Student Name

Marcel Corbeanu, from Romania.


11.06.2011 – 03.08.2011 (worked on it almost every day, at least 4 hours)

Project Details

  • Word Balloon
    • Create one Word Balloon Type for another event
  • Flag Pole and Finish
    • Mario jumps on Flag pole and goes down it
    • Mario walks to the castle and finishes
    • Score from time adds to points
    • World 1 – 1 is completed :)
  • Scene Transition Wipe
    • Implement Scene Transition Wipe between each Scene
  • Design the Next World
    • Create a new world for Mario to Explore
    • World must have a beginning and end
    • Optional: Create a new gameplay element (Ex: Moving Pads)
  • Menu Screen
    • Create a complete Menu Screen with Start, Credits, Quit

Note that the 1st and the 3rd assignment aren’t present in this sample, mostly because I don’t think they look good in the final game (I don’t like the wipe transition and I don’t think the balloon looks too nice there).
As for the 4th one, I designed this world almost from scratch. I took care of many many changes, including objects combining which was done in groups of 3 (where the same material was used). I also designed the underground area and I put many hours into it (including into the tube teleports side and top logic and the static camera logic) so I think I demonstrated that I know how it needs to be done at the professional level.
If I start and design a new level from scratch … well, then that’s another thing as I have to do it right and it’ll take me about 30-40 hours of work, maybe more; and I don’t have that time now, I think I can better use it to develop my Unity skills.

Software Used

  • Unity 3D
  • Adobe Soundbooth CS5 – for editing the sound files
  • Adobe Photoshop – small design work, like the flag pole

Final Thoughts

I did all sort of updates, upgrades (call it how you want) to the game so that it’ll work better and feel like a combination of the original Super Mario Bros and the new Nintendo DS New Super Mario Bros. Many many many hours of coding.
Here’s a small list of improvements and bug fixed that I worked on in the last month:

Tubes teleporting logic was changed so that it’ll not have any bugs.

Added tubes teleporting logic for top tube exit and side tube entering (like we have on the underground area).

There was also some camera work related to tubes teleporting because the camera had to be static on tube exiting (like in the original Mario titles). Camera logic was changed completely to make it more like the original game but also for performance reasons.

Player control logic changed to reflect the new improved movement that the Nintendo DS version has (interpolate from zero to walk/run speed or from walk to run speed and vice-versa). Jump controlled height logic changed as well (better version based on triggers rather than based on CharacterController flags).

Enemy control logic upgraded, jump controlled height logic added so that it’ll bounce from boxes when jumping (like the player does).

Block script was altered to include, among others, invisible blocks.

Sounds volume was adjusted where needed.

Underground secret area was added to level 1, complete with camera position, etc.

gameManager.js and guiManager.js files area used to take care of global functions like playing a sound, adding points text, etc.

GUI is scaled based on resolution so buttons will be bigger or smaller based on a particular game screen resolution.

I took care of different optimizations like:

  • Combined objects close to each other that share the same material.
  • Caching as many values as possible in private or static variables (like transform.position values that used to be called every frame).
  • Raycasting only against dedicated layers and a max of 5-10 rays/frame.
  • Enemies and coins get activated only when the player is in their proximity (basically scripts don’t run when these items are far away).
  • I paid attention to the number of trigs in the scene (for this game the number is very small but still).
  • I paid attention to the number of draw calls (the target was to be under 500) and now they are under 50 (sometimes their number is under 30).
  • Use of animations instead of math animations, where possible (actually this was already setup as we’re kinda working on a 2d sprite sheet based game, but still).
  • Use as few complicated math functions as possible and not doing any complicated calculations every frame (doing the calculations only once and caching the values in private or static variables).
  • Static typing instead of simpler, but slower, dynamic typing.
  • Use of predefined arrays (Component[], etc), which is very fast.
  • Optimized (compressed) textures, especially the big texture sheets.
  • When exporting the game, I selected “batching items” option which is also a good performance improvement.
  • Not using GUI stuff for in game rendering (this was initially there, but still) – expensive on draw calls.
  • Many of the references to important game objects were cached in gameManager.js so they care calculated only once per game.

All the animations in AniSprite start from the 1st frame of the animation, regarding Time.time.

There’s also an option to play an animation only once.

I changed the way the enemy was killed for different situations:

  • Hit above – will vanish and we’ll see a vanish dust
  • Killed by either fire or from below (by hitting a block with the head) – default Mario enemy die stuff where enemy will fall down, in front of the screen
  • Fall down the edge – will hit the killbox and it’ll be automatically removed by the engine

I cleaned the library and removed most of the unused items, like different blocks, different copies of enemies, prefabs, etc

Mushrooms pickup and fire flower pickup transitions were added:

  • When the player will collide the fire flower game will freeze for under a second and we’ll see a material animation
  • When the player will collide with the super mushroom game will freeze for under a second and we’ll see a size animation
  • When the player will lose the super mushroom (will become small) game will freeze for under a second and we’ll see a size animation

Immunity was also added and player blinks for the entire time (couple of seconds).

Camera script was completely changed. Among others the SmoothDamp function was replaced with a simple easing (not time based) – better Mario style camera effect.

Points system was added, with screen display, like in all Mario games.

Of course, I took care of the flag pole logic, exchanging time left to points, game end logic, etc. (no end animation though)

I did many adjustments to the collision boxes for both player and enemy as well as for the pickup items (mushrooms, coins, fire flower) so that there wouldn’t be any collisions related problems (I had some problems initially)

Intensive use of layers and layers collisions matrix so that, for example, 2 enemies will not collide with each other but collide with other items on other layers.

Testing, testing, testing, testing, testing …. And more testing.

I made sure that some of the things that need to happen only once are actually going to happen only once (like for example, when the player will kill the enemy, we don’t want it killed twice).

One camera related note: one camera cam render more than one layer and this can be really useful if you’re working with layers and layer based collisions.

Fireball logic completely new (collision detection done using raycast). The fireball is now bouncing correctly.

There are 2 AudioSources in the game (one used for bg music and one for different sounds). Bg sound is played using AudioSource.Play() and is setup to be a loop and the normal sounds are played using AudioSource.PlayOneShot().

Ggame won/game lost logic incorporated into the game (Note: game will be over when time will run out, regardless the number of lives left).

Make sure that all the pickup items (muchrooms, etc) that are moving and can fall down are removed once not in sight (for example, you can remove them when they hit the killbox).

Player detection by enemy is done based on raycasts not based on counting distances. This takes care of the problem when the enemy is above the player but the x-axis distance is still in the margin; also, it takes care of the problem where there’s a block between the enemy and the player but the player is in enemy’s search range.

Pay attention to each yield WaitForSeconds(n) statement because if you chain them and place them in the Update loop you’ll end up with many calls which, among others, will cause a performance problem.

Make sure that once dead, enemies will not move, cast rays, do calculations, etc (another good performance improvement).

Made some changes to each and every prefab that is used in the game – I changed their initial position to be at (0, 0, 0).

Added some of the sounds that were in the library but not used (like the start sound, end sound, end music, etc).

No bounce for the player when hit by enemy, but instead we play the shrink animation and we give him a couple of seconds of immunity.

Adjusted a couple of the CharacterController variables for better gameplay.

I took care of the background items, scaled them, arranged them, etc, so that they will look nicer. Also, I’ve added a mountain in the areas where there’s no front land so that the background land will not look strange.

Camera calculations and movement are done in LateUpdate().

Some other many improvements that don’t come in my mind and that I don’t see now in my 20 pages lists of modifications :) .

Break down your Time

  • Research
    • Maybe 10 hours, not counting the videos here
  • Art
    • aproximately 5-10 hours
  • Design
    • aproximately 5h:00 – I had to desing the flag pole stuff and some other small stuff
  • Coding
    • 270h plus or minus a couple of hours (it’s one and a half month work, it wasn’t easy but it was fun)
  • Playtesting
    • Included in the coding time above, I can’t say for sure, I did testing every day

Thank you again for all your work in putting together the huge list of videos and the documentation for the tutorials, exams and labs, as well as for the graphics design.

Filed in: English, Unity 3D
Tags: , ,

Related Posts

Bookmark and Promote!

11 Responses to "Walker Boys Studio – Unity Training – Lab 4 (Super Mario Bros)"

  1. rick says:

    Hey, I just stumbled on your blog while I was looking for the walker boys tutes (I couldn’t remember their names, lol) and I just wanted to say, that these write ups you’ve done are really awesome. It’s nice to see how other people handle assignments.

    Did you ever do Lab 5? It’d be neat to see what changes you make to that one as well!

  2. Marcel says:

    Hi Rick,

    I’m glad you find it useful :)
    Unfortunately, I haven’t done any work on Lab 5, I decided that I learned what I needed to learn and the way they approached Lab 5 seemed too “complicated” (too many variables, code wasn’t optimized, etc) and, by the end of it, I would have done too many changes :)
    I would love to see your result :)

  3. rick says:

    Hey Marcel, thanks for the reply!
    That’s fair enough, really. If you feel like you learned what you needed to from the first sets of labs, then not doing the last one makes sense, especially if you’re now armed to work on your own big thing!

    I knew about these videos last year, but never got around to sitting through them. I’ve been doing a bit of tinkering on my own, but I think I need some workflow help and more knowledge on the ins and outs of the platform, which I hope these will provide!

    I think I might do some posts like you, if you don’t mind, providing my findings and experience in a similar format! I might translate the code to C# while I’m at it, since it seems to be in javascript.

    I think you’d have a very interesting blog, I wish I could read romanian! Your posts on animation would be really informative, I bet.

  4. Hey Rick,
    About the language … this I can answer.
    You can use Google Translate, which is on the right top corner of the page. Is doing a good job on english :)

  5. Marcel says:

    Yeah, writing C# code would be a good idea, I might do that at some point, who knows? :)

    I remember there were some tutorials in C#, provided by some other guys. Maybe you can find some info in this forum thread, http://forum.unity3d.com/threads/69938-Unity-3-Video-Training-Course-%28FREE%29-Walker-Boys

    Regarding the language, as Cristina said, you can use Google Translate to read the website, hope that helps.

  6. mark says:

    I just stumbled upon this and love what you did with it. I just did what he wanted as the extra stuff and decided I knew enough about unity and the api to work on my own 2D game. Do you have the project or any of your scripts available to view or download? I would love to see the changes that you made to the tube script and to the enemy ai.
    Also I created a GUI and Game manager as well. It seemed much easier than rewriting the code or calling it from different places.

  7. Ara says:

    Hi, would you mind uploading the full finished product code? I am currently working on this project, actually I am almost done, but I am having problems with the path nodes..:( Please help..

  8. ali murad says:

    i am learning unity from walker boys tutorial. i am to face a problem in making mario clone 2d from this link


    i can download project files (2D Mario Clone Project Files (140 mbs): Mirror 1).i think they are deleted from rapidShare
    if you have these files kindly share with us.

  9. I think the smartest thing to do would be to email the Walker Boys as they will gladly send you the files, I’m sure :)

    Good luck!

  10. Abhishek says:

    Awesome article and played your game , it was super smooth and fun to play. I am following WalkerBoys tutorials myself and love it.
    Can you tell me whether you had any programming or game developing experience before learning walker boys tutorials?
    I am a newbie and following their tutorials are fun.

    Thank you

  11. Thanks for your kind words Abhishek :) I’m glad you liked my game.
    To answer your question: yes, I had lots of programming and game developing experience before making this game. My suggestion will be do follow with their tutorials and later come back here and read my post again, I’m sure you’ll get a kick from it once you have done the game yourself and are just looking to improve you code or game programming skills/approach :)

Leave a Reply

Submit Comment