Tuesday, October 27, 2015

Game objects and components

Let's look on one of the most important concept in the Unity - game objects and components.

Everything we drag&drop (e.g. camera or sprite) on the game scene is called game object. On the C# script level the game object is an instance of the GameObject class (Note that GameObject class is sealed, so you cannot inherit from it). GameObject class does not do much on its own. It is rather a container for specialized classes, which are inherited from class of other type - Component.

For example: If I drag and drop the camera to the scene and I attach a script to it, you will see in the Unity editor something like this:


Camera in Unity editor UI
By dragging the camera to the scene I have created a new game object with several components in it. Let's now edit the script attached to the camera and let's put into its Awake() method following code:
Component[] components = GetComponents();
foreach (Component c in components)
{
   Debug.Log("Compontent: " + c.GetType() );
}
What happens there? The code in the script defines a new class inherited from Component base class. When the game is started the new object of the defined class is automatically instantiated and its instance is attached to the game object container like any other component.The Component class has a method GetComponents(), which returns list of all components of given type, which are attached to the game object to which the component (i.e. object from our script) is attached to. So in the case of camera the above code will create following list of class names prefixed with namespace. Note that the last item in the list is the script class itself:
UnityEngine.Transform
UnityEngine.Camera
UnityEngine.GUILayer
UnityEngine.FlareLayer
UnityEngine.AudioListener
RetroEngine.PixelPerfectCamera

Sunday, October 25, 2015

Samsung SmartTV?

Finding that Unity supports Samsung TVs was a little surprise for me. Unfortunately Samsung is the only supported brand and I did not find information about the planned support for other vendors' TVs and operating systems e.g. for LG's webOS or FireFox on Panasonic.

Smart TV in general is not really a game platform - TVs have performance problems and their remote controls usability is far from the standard game pad, so checking available games in SamsungApps and LG SmartWorld application stores I was not able to find anything that is worth to install and run. But it is not only Samsung and LG - comparing to others those brands are even doing pretty well because TVs from other vendors like SONY, Philips, Sharp, VESTEL, Toshiba, Panasonic, Grundig, etc. are ignoring games almost totally and they focus mostly on entertainment video and audio applications. Might be new Apple TV and android TV will bring some change there.

Working in the video streaming industry I have access to many Samsung Orsay (2012-2014 models) and Samsung Tizen TVs (2015), so I decided to launch a small demo to see how it works.

The important is that not every TV from Samsung is compatible with Unity. See the list of supported devices:


On the other side I was able to install and run a demo application on every 2013+ TV model I found (including cheap low-end 2013 5xxx TV series). To launch the application in the debug mode, the Unity Launcher application needs to be installed and started on TV first. Unity Launcher is available in the SamsungApps application store:

Samsung Tizen Unity Launcher 
Samsung smartTV Orsay (2013)  Unity Launcher
Samsung smartTV Orsay (2014)  Unity Launche
To upload the application the FAT32 flash drive with sufficient space for game upload must be inserted into TV's USB slot. Once the Unity Launcher is started on TV it exposes the web http interface (using port 8899) for application upload, launch and for accessing debug logs from the Unity framework combined with Debug.Log() output from the application.

Unity Launcher web interface
In general my short test on few devices shows that using Unity it should not be a problem preparing a simple game for Samsung TVs. I did not face a single problem - everything during my test worked as expected, which is not really common situation in TV world:)

Doing something real - sprites and sprite-sheets

I started playing with sprites. For testing I downloaded dog from Wolfenstein 3D and some other retro games sprites. I played with the sprite-sheet editor and sprites packer (used to put together individual sprites into a single texture called atlas). In general I just looked around Unity and check how those tools are working.


Examples, which highlight the fact that nice 2D animation does not require too many sprites:


Wolfenstein 3D
Batman Returns 

Castlevania

Here are listed several sprite database pages, which are good sources for inspiration:

Friday, October 23, 2015

Starting game development (or at least writing about it)

I was big computer games fan in my childhood. I started playing on Commodore 64 and in the beginning of 1990 I received my first 386 PC with MS-DOS, where I played all the best RPG dungeons of that time like Eye of the Beholder (1990), Dungeon Master (1988), Lands of Lore (1993), Betrayal at Krondor (1993), The Elder Scrolls: Arena (1994), Ishar (1992) trilogy, Realms of Arkania (1992) serie and many other titles. 

From my perspective it was the golden age for RPG – pixel art graphic, great stories and mystical fantasy worlds with hours of playtime without Internet, so every problem had to be solved by players… 

Here are some images if you do not know games I am speaking about:


Ishar 2

Dungeon Master

Eye of the Beholder 2

Lands of Lore
It was of not only RPG genre that fascinate me – there were tens of other adventure and strategy titles and I spent with my friends days and weeks by playing games and ignoring what’s happening around in a real world. Games stopped interesting me when the 3D era come – in fact last games I was really mastering were Doom 2 and Warcraft 2 and I totally abandon any game playing around 1998.

As a C++ developer I become later in my professional career again interested in games, when Windows Mobile and first Symbian phones arrived to the market. I have tried to come with my own games, but it all ends without success, because I had no time to finish anything being always busy with some other projects. Bellow are some screenshots of my attempts - I tried to create the classical RPG dungeon, which I called Thormdeil:






























































Now after 10 years after my tries on mobile phones I am no longer developing, so when I saw the Unity (https://unity3d.com) for the first time I realized that it is probably my last chance to become hobbyist game developer as I always wanted. 

To increase my internal motivation I started this blog, where I plan to inform everybody and nobody (I do not expect to have readers), how it is to start game development knowing nothing or little about game principles and physics, close to nothing about C# and having zero abilities to create graphics on one side, but being enthusiast and full of energy to create own small 2D pixel art games.

Wish me luck,,,