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
Marcel Corbeanu, from Romania.
11.06.2011 – 03.08.2011 (worked on it almost every day, at least 4 hours)
- 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.
- Unity 3D
- Adobe Soundbooth CS5 – for editing the sound files
- Adobe Photoshop – small design work, like the flag pole
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
- Maybe 10 hours, not counting the videos here
- aproximately 5-10 hours
- aproximately 5h:00 – I had to desing the flag pole stuff and some other small stuff
- 270h plus or minus a couple of hours (it’s one and a half month work, it wasn’t easy but it was fun)
- 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.