Wednesday, June 17, 2015

[Unity 3D] Tutorial 3: Survival Shooter

This is a top down isometric style game in which you basically need to shoot everything that moves to survive (a.k.a. survival shooter). You impersonate a boy who's dreaming that all of his toys have come to life. This is the last beginner level tutorial and covers the following topics:

  • Use layers to isolate game objects
  • Animations: use and control transitions in model animations, animate GUI objects
  • Ray casting
  • Input.GetAxis vs Input.GetAxisRaw
  • Movement normalization
  • Time.deltaTime
  • Use Lerp to smoothen transitions
  • AI: use NavMesh, bake a navigable area
  • More on GUI components (CanvasGroup, Slider, Image, etc.)
  • Awake method
  • LineRenderer
  • Alternative method for timers: InvokeRepeating

These are the main modifications I made to make it work in Unity 5:

  • Disable the flag "Has Exit Time" so the animations are in sync with the events. This cancels the ongoing animation when there is a transition to another state
    • Open the Animator Controller
    • In the Animator window, select the transition to modify
    • In the Inspector, locate and uncheck the flag
  • Change the LineRenderMaterial to use an Unlit/Color Shader. The LineRenderer renders the lines black under certain shaders.

The export to WebGL in this project is not so good. The scene appears very dark and the textures have some kind of black spots, but it should look like on the image below. I believe this is because of the preview version of the WebGL player, or maybe due to incompatibility of the assets with Unity 5. Anyway the game is playable, so give it a try and let's see how much you can last!


Thursday, June 11, 2015

[Unity 3D] Tutorial 2: Space Shooter

In this second tutorial they teach you to make a very basic top down space shooter. There is a little more scripting than in the first one and involves using more game objects and features. You learn to:
  • Change the resolution of the game
  • Modify and save a layout
  • Import assets from the Unity Asset Store
  • Work with mesh models, textures and materials
  • Use mesh colliders and capsule colliders
  • Instantiate and destroy prefabs
  • Add background music and sound effects 
  • Use tags to identify game objects
  • Work with coroutines
  • Use the yield instruction
  • End a game and reload it
  • Use methods and parameters like Mathf.repeat,Time.time or angularVelocity
  • Differentiate between screen space and viewport space
The tutorial is again very easy to follow, but it has been developed in Unity 4. If you are using Unity 5 then you will need to make a few modifications to make it work:
  • Mesh colliders won't work unless you enable the Convex flag
  • Some static references such as rigidbody have been removed:
    • Unity 4: 
      • rigidbody.AddForce(movement);
    • Unity 5: 
      • RigidBody rigidbody = GetComponent<Rigidbody>();
      • rigidbody.AddForce(movement);
  • The render settings menu has been moved:
    • Unity 4:
      • Edit > Render settings
    • Unity 5:
      • Windows > Lighting
  • The GUIText is no longer accessible from the Create menu. In Unity 5 you need to create an empty game object and then go to Add component > Rendering > GUIText
And that's all I can remember at the moment. I encountered some of these issues already in the first tutorial but I forgot to mention them in the post.

Finally I added a couple of extras to try new things and make it a bit more interesting: a scrolling background and a blinking text. I will explain how to do it at the end of the post in case someone is interested. I could have added more things like parallax or smarter enemies, but I just want to move on to the next tutorial :-)

And here's the result:


Input settings:
- Move with the arrows
- Shoot with the space bar or the left mouse button


How to make a 2D scrolling background

For the background I followed this live trainning session, which shows several ways to do it. I tried the first two and in the end I kept the version that uses the texture offset to create the effect.You just need to create a Quad, assign it the desired texture and add the following script to it:

public class OffsetBackground : MonoBehaviour 
{

public float scrollSpeed;
private Vector2 originalOffset;

void Start ()
{
originalOffset = GetComponent<Renderer> ().sharedMaterial.GetTextureOffset ("_MainTex");
}

void Update () 
{
float offsetY = Mathf.Repeat (Time.time * scrollSpeed, 1);
Vector2 offset = new Vector2 (0, offsetY);
GetComponent<Renderer> ().sharedMaterial.SetTextureOffset ("_MainTex", offset);
}

void OnDisable ()
{
GetComponent<Renderer> ().sharedMaterial.SetTextureOffset ("_MainTex", originalOffset);
}
}


How to make a blinking text

Making a text blink is very simple. You just need to set the text of the GUI element to blank for a few seconds and then back to its original text for a few more seconds, alternatively. In my case I used it for the "Press 'R' to restart" label.

First I created this coroutine:

IEnumerator BlinkRestartText()
{
while(restart)
{
restartText.text = "Press 'R' to restart";
yield return new WaitForSeconds(blinkingRate);

restartText.text = "";
yield return new WaitForSeconds(blinkingRate);
}
}

And then modified the SpawnWaves method as follows:

if(gameOver) 
{
restart = true;
restartText.text = "Press 'R' to restart";
StartCoroutine(BlinkRestartText());
break;
}

That's all. When the game is over the coroutine is launched and runs until the restart flag is set to false. This happens when the player presses R and the game is reloaded (the method Start will be called by Unity). As for the content of the loop, it will first of all set the text in the GUIText object and wait for a few seconds, and then set it to blank and wait for a few more seconds, and so on. The use of the yield instruction ensures that the game won't be paused while waiting, and that the function will continue from the line after the yield after the wait is over.


Tuesday, June 9, 2015

[Unity 3D] Tutorial 1: Roll a ball

Last week I finished the first Unity tutorial. They have a bunch of them on their website for both beginner and intermediate users, and they are really well explained. You can choose between two learning paths: a set of projects with increased difficulty, and a set of lessons sorted by topic. Personally I think it's best to start with the projects and check the topics as you need them.

In the first tutorial you get to learn the very basics of Unity:

  • Create a scene
  • Add game objects to a scene and enable/disable them as needed
  • Use scripts to define behaviors
  • Convert a game object into a prefab that you can reuse
  • Read keyboard inputs
  • Create a camera that follows the player
  • Basics of physics and collision management, and some hints for its optimization (Rigidbody, static and dynamic colliders)
  • How to display text
  • How to export a game

Here's my version exported as WebGL:


Wednesday, June 3, 2015

Focusing

After doing some research I have come to the conclusion that I want to be a serious games developer. That is, games whose primary goal is not to entertain, but to serve as a training or a teaching tool, to help marketing, etc. This doesn't mean though that these kind of games cannot be entertaining. In fact I believe that they should be, so they can better achieve their goal (specially if their aim is to be educational).

This being said, my focus of interest is still archaeology and history. The kind of games that I would like to make would use historically rigorous models, real stories and characters, and would be educational. I recall a game that I played during childhood and illustrates quite well what I have in mind. It's called "Versailles 1685" and I remember finding it very interesting at the time. What I liked about it is that it takes place in Versailles palace and you get to walk around its different rooms and areas, view and read about its paintings, meet many historical characters and learn about them and about life in the palace. Here some images of the game:



So now it's easier to know what I need to learn. I searched for job offers in serious games and game development in general, and the key skills that I will need are C++ and Unity 3D. Besides this, most of the offers require professional experience in game development, with at least one published game, and about half of them require to have a master in game development. Therefore I've been considering signing up for one of the two main masters in video game development that exist in Barcelona:
From the one taught by UPC I like that it's cheaper and as a UPC Alumni Premium member I get an additional discount :-D Also they use game engines, which would be useful to learn (I guess), and the master has for some reason more visibility among companies. The annual event in which students present their works is always full of people.

The one by UPF is more hardcore. They don't use any game engines and instead expect you to implement your own. I see it as a great learning experience. Another good thing about it is that they split the contents into two independent specializations: design and programming. That means that programmers can focus on just programming and skip the modelling and animation part. Finally, the amount of classroom hours is higher.

I was almost convinced by the one at UPF but a conversation with my boyfriend and several other friends who are professional game programmers walked me out of it. In their opinion masters are too expensive for the benefit they provide, and game companies don't care much about the education section after all. Companies value experience and motivation. Since I'm already a developer they believe that I can learn the same or more on my own. So their piece of advice is that I keep my money and start making copies of simple games or join an indie group. I just need to have a few small projects in my portfolio, know the main concepts in game development and be well versed in the language. And if they all agree on that then I guess they're right.

Next stop: becoming an indie game developer.

Thursday, May 7, 2015

Back in business

Hello again!

It's been more than one year since my first post and it may look like I have lost all my motivation THAT fast. Fortunately that's not the case, I just didn't have anything to write about in relation to 3D or Virtual Reality (not that I can write much about it today either, but today is a big day). But first things first, what have I been up to this whole year?

After quitting my job in February I had lots of time but no money. I had planned to attend the Italian Virtual Heritage School 2014 in summer, a 10-day long program organized by V-Must (Virtual Museum Transnational Network) in which I would learn the basics of virtual archaeology in a practical way: laser scanning, use of drones, photogrammetry, GIS, 3D modelling and so on. So I decided to look for a temporal job until the school started, and so in March I was already working at a new consulting company. It was more or less the same as my previous job (Java programming) but completely different at the same time. Smaller company, realistic timings for projects (no overtime!), great people (not that there were no great people at my previous job as well, but here every single one of them was awesome!), more innovative (thanks to my project leader!), and a more relaxed environment in general. Another difference is that it wasn't application maintenance, but a whole new project starting from scratch. This allowed me to learn things properly, and for that I am very grateful.

In May I received devastating news. The Italian Virtual Heritage School had been cancelled due to lack of attendants, but it might be postponed until October. There was still a chance. Several months passed and there were no news of the school ever starting, so fearing the worst I started looking for alternatives. The school never took place indeed, but I found an online Master program starting in November that was focused on Virtual Archaeology and Preservation of Cultural Heritage. It seemed to fit my needs and so I decided to sign up, but November came and there were no news again. I started to get really frustrated, like I would never be able to achieve what I wanted. I was being so unlucky! I must confess that the lack of news along with other aspects around this Master made me have serious doubts about it being a serious program, and I was considering giving up. Meanwhile I was still working at my temporal job and was feeling very comfortable and happy with it. I also took a course in Android development in November-December and I am now a certified developer, so I had new worlds to explore. But finally the news came and I knew that the Master would start in January.

January to March 2015 have been very busy. I tried to combine work with the Master, but the workload of my studies was too heavy to continue with both, so very sadly I had to quit my job in March. In April my boyfriend and I had decided to go on a trip to Japan, and we have spent the last 4 weeks there (amazing trip BTW). And I just came back 4 days ago, ready to take over the Master.

The last few days have been quite frustrating once more. I have little info concerning the contents of the Master, as little as just the names of the chapters and the name of the professors in some cases. And with some exceptions, so far the chapters have not been very useful to me while the workload is insane, and I am worried that the whole thing is going to be the same. I feel like I'm wasting my time, since I am above all a developer and I don't really need or want to write academical papers, or fund applications, or job offers (these are some of the activities that I have to deliver). I'm not saying that the Master is useless by itself, it's just not that useful for a person with my profile. So I am considering putting these studies in a second place, follow only those chapters that I consider useful and invest the rest of my time experimenting with new technologies. Learn by doing, that's the best way to go. The worst that could happen is not getting the Master certificate, which I don't care that much about. I believe that knowledge and experience are more valuable than a paper saying that I did this or that, as long as I can prove it somehow.

With these things in mind yesterday I sent an e-mail to my coordinator and I am now awaiting her response. I'm just hoping that she understands my point of view and won't take it in a bad way.

Today is a new day and I've been thinking on the next steps, I need an action plan.

Action Plan

  • Get to know the context
    • Read about what's out there in terms of software, devices and applications
    • Look for people and companies involved in the development of VR applications. Find out which are the desirable skills in a potential employee
  • Learn
    • Focus my efforts on learning the key skills to be hirable
    • Create demos for Android using AR. Maybe also for IOS.
    • Find out which applications/engines/frameworks are the most used in the creation of VR/AR applications (e.g. Unity, Unreal Engine) and create demos
    • Take whatever courses or workshops are available in relation to VR/AR
  • Create a portfolio
    • Create a website in which I can publish my demos (or use this blog)
  • Look for a job
    • Not any job, a job in the field :-)


Tuesday, February 25, 2014

There is life out there

I used to be a programmer at a multinational consulting firm. Working there had its good things and its bad things, as everything else in life. But basically I had no time. Not for myself, or for my family and friends, or to learn or to be creative. I was some kind of robot living just for the sake of working, always under huge stress and over-timing a lot, and it felt wrong. I wanted to work to live and not the opposite, I wanted to enjoy doing whatever it is I do for a living, because there is nothing like being passionate about what you do and because time is priceless. There had to be another way...

Recently I decided to quit my job, so I could have time to do all of those things I always wanted to do. It's been just one week since I started enjoying my freedom, and I already feel like a new person. I started doing exercise and cooking more. I explored my own neighborhood and stepped into many great undiscovered places. I had time to catch up with a few long lost friends and also to read a bit every day. Also started to sleep more and I am finally feeling well rested. I feel more energetic and happy in general, and this makes me be inspired to start learning and doing other things, being productive.

Looking further back in time, I also used to be a Computer Science student passionate about Computer Graphics. At university I took every subject I could that was related to the field, and I was offered a position to work at BarcelonaVirtual Reality Center. This was my first contact with VR and I found it incredibly interesting. After a few months I had to quit to go on Erasmus and work on my master thesis, but the experience there gave me new ideas for what I wanted to do next. Already abroad I was lucky to find another VR lab and a professor that accepted to be my supervisor. He had some very interesting proposals for a master thesis, and I ended up creating a virtual museum all by myself. I loved it because it had everything that I like: creativity, programming and history. It was a project in which I could bring together my technical and my artistic profiles. I enjoyed doing that a lot, so going back to the present, why not turn something like that into my job?

The last couple of days I have been setting up an office at home. My goal now is to learn everything I need to work in the creation of virtual museums, starting with 3D modelling. Risky as it is, I want to give it a try. Job positions in the field are narrow and there is also a possibility that I won't like it as much as I think now. But I would hate to not even try and growing old with that annoying "what if...?" question always in my mind. Moreover, even if my mission would not be successful, I believe that everything we learn is somehow useful. Besides being a great self-learning experience, there are other fields I like where I could use my newly acquired skills, such as game development or the film industry. So it's a win-win... Or that's what I tell myself :-)

So here I am writing my first post on my first blog ever. This has just been a small introduction about myself for you to understand my background and motivations, but the idea is for this blog to become more technical than personal. My purpose is to keep track of everything I'm doing to achieve my goal, for several reasons:
  • To centralize all the knowledge in one place and go back to my notes whenever I need to refresh my memory
  • To serve as a resource to help others who are also trying to learn
  • To boost my motivation by exposing progress
  • To remind myself why I'm doing what I'm doing, when critical times come
And this is all for now. Hope to come back soon with some 3D!