Build 10 games and learn game development along the way in this fast paced game development course

Get the source code of 12 commercial games, loaded 50+ million times, and learn the secrets of game design

Learn how to make a successful Flash game from a real world example. Fully commented source code

Create realistic Flash physics games from scratch with advanced features, from Angry Birds to Crush the Castle

From zero to a complete Unity3D game: 3D Concentration using C# – step 2: skinning and timing

Time to show you the second step of our Unity3D Concentraton game. In step 1 I showed you how to create a cube primitive, resize and rotate it as well as react to mouse input and change color.

Now it’s time to add some kind of time listener to make it flip again once we saw its value, find another way to rotate it (actually there’s no need to find another way to do it but if you want to master a language you should know a lot of ways to do the same thing) and start texturing it.

Bad news first, you can’t apply different textures/colors to different faces on a primitive Unity3D cube. This means you can’t have a green cube with a black face. There are a lot of different ways to accomplish this task, from creating the cube itself with a 3D modeling software like Blender then playing with UV mapping to creating the cube programmatically, vertex by vertex, then assign different textures to different faces.

Since it’s just a concentration game and we don’t need such a great number of stuff on the screen, we can choose a dirty way to do the same using some unnecessary polygons, which won’t affect the overall speed anyway.

That’s why I added a primitive quad to the primitive cube, stick them together so I will be able to add a texture only on one (fake) face of the cube.

Look at MainScript.cs:

The other interesting thing about Unity3D is the way it handles timed function using Invoke. This way I was able to call a function which covers the tile 2 seconds after it has been shown.

This is CubeScript.cs:

And this is the result:

Click on the tile and watch it flip then after two seconds flip again.

Download the project. Next time, a lot of tiles on the screen!

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 2.29 out of 5)
Loading ... Loading ...
Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 3 comments

  1. ShockWave2048

    on November 6, 2013 at 6:36 pm

    Is unity/c# have some Tween classes for animation?
    For work as “lanch and forget” with animation.

  2. Tabrel

    on November 11, 2013 at 6:35 am

    I was using Unity 4.1.5 and it didn’t have a quad primitive but upgrading to 4.2.2 fixed that.

  3. John

    on November 13, 2013 at 3:12 am

    Yes there is a tween library for unity….its called iTween and its free and mimics most of the animation features you find in Flash

Thank you for the download!!

I hope you will find it useful and make something interesting out of it

To keep up to date with the blog, why don't you like my Facebook page and follow me on Twitter?

Want to learn more? Don't miss this:

Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now

×