Game programming - Unity 5

My first game in Unity part1 – Total beginner, hello!

Good day!

That’s something I’ve been wanting to do for years, but never really took the time for it. I did something yeaaaaars ago (with the old 2D program RPG Maker and also another that was called – I believe – “Game Maker”, also all in 2D and where coding was not mandatory – and I had actually created a cool small game that got lost a long time ago).

In the recent years, Unreal Engine and Unity both became free, whereas the business model was way different not that long ago. And without a sack full of gold or mortgaging your 3 hearts and 5 livers, only big companies could afford them. But now that it has changed, anyone can get to it!

So I decided to learn how to use Unity and make my first little game out of it.

Why Unity?
Well, there is no GOOD reason about it, as I’m not the pro-[insert-a-brand-here] type, but I’d say that I got marked by the general opinion that is “Unreal Engine for AAA, Unit for small/indie games”. Which is not false, as the most famous games were made within the UE (I got the first Crysis in mind, but there is the Unreal Tournament series, Deus Ex, Bioshock, Injustice: Gods among us, the Gears of War series, etc.OK, not Grand Theft Auto, but hey, that’s Rockstar!
Also, I sometimes play (and quickly get bored) on my tablet, and so many games are made with Unity! So obviously, it sends the message “look, Unity is super simple if you want to make your own mobile game and get dirty rich fast!”. Riiiight…
One more point: I saw on the web some stuff like “you can make a game with Unity without coding even ONE line”.

How I started
I downloaded Unity a few years ago on my desktop PC, but because I got extremely-super-duper-over-9000 busy in rebuilding our house, I didn’t have space for myself to set it properly, nor enough free time. So just recently, because I bought a second-hand laptop, I thought “hey, why not download Unity again and see if it runs on that machine?”.
No, it’s not a monster, quite the opposite! It’s an i3-6100 with 8GB and Intel HD Graphics 520 (17 inches), running on Windows 10 Pro (and its unbearable auto-updates come ooooon!!!). So far, the worst has been the HDD that is way too slow (or old, or both). Probably a lack of RAM too, especially with Firefox using so much, what a pain, really… I think I’ll look into it seriously.
Anyway, I’m not going to complain about an 80-buck PC. :)

Surprisingly, Unity works like a charm! Although whenever I open it/load a project, it takes… time. So that’s great, because I still haven’t finished the room where I plan to put my desktop.
One thing that I must precise, so that you can understand why I can handle it “smoothly” from the beginning, is that I have used Cinema 4D for years (it’s a 3D modeling program like Maya, Blender, 3DSMax). As a hobby, but it doesn’t change the fact that I am familiar with that type of interface. So when I launched Unity, I wasn’t lost at all. I directly held the Alt key and the mouse buttons to see if I could navigate in the display windows – and it worked! I then reinstalled Cinema 4D to see if it would run too, because I didn’t want to waste my time if in the end I couldn’t make 3D objects to import in Unity on that laptop. Fortunately, it works fine.

What I want to make
Last month, I played and “beat” Prime Peak, a simple yet fun game. I’m not sure what type it is, a sort of hill-climb racing game? It’s in 3D but using the 2D physics, which means that the environment and vehicles are in 3D, but the car moves on the xy axis only (left-right-up-down), like a lot of Nintendo games since the Wii (Mario, Donkey Kong, Kirby…). We can gather coins (money to upgrade the car or buy a new vehicle) and must get to gas tank refills before running out of gas, in order to reach the finish line. It’s a simple concept, and that’s not the only game of that kind, but it’s the only one that has – and that’s only MY opinion – good physics and pleasant graphics.

In order to learn, what’s better than making something inspired from a creation that one enjoyed? Of course, I’ve got plenty of ideas, but one’s got to start somewhere, right? And because that sort of game has a very limited gameplay (not in a negative way), I thought it’d be less complicated than directly starting with a 3D platformer.

First steps in Unity
Soon after having opened Unity and clicked on buttons here and there, I started looking for cars tutorial. I started with one based on 3D physics (such as Gran Turismo, Forza, etc.: an environment like ours), using a box as the main part of the car, and 4 cylinders for the wheels. Nothing fancy, but at least it was moving accordingly, although it was not very satisfying. I’ll talk about it another time, but setting the wheels colliders is absolutely not user-friendly. Many people on the web are complaining about that, stating that there doesn’t seem to be any logic behind all the parameters, and indeed it is hard to find how they are all affected by each other.
One important thing I want to point out: I wrote, as a possible reason to use Unity rather than another engine, that “you can make a game with Unity without coding even ONE line”. I didn’t look into that, as for me I don’t think it is possible to create a proper game without coding, and I didn’t jump into that new world thinking that I’d want to avoid writing code. Anyhow, even by using a specific UI that allows one to create things without coding (I don’t know how that’s called yet, but I’ve seen screenshots), there is code behind that.
So I directly started typing in C# (pronounce “C sharp”, yeah… figures…), of which I knew NOTHING. Like, what the fuck is that stuff? I’m still thinking that, by the way. I had seen other languages, and always wondered the logic behind them, as they don’t seem logical to me. After having started “learning” C#, I’m still thinking that it lacks of logic, but it’s way too early for me to talk about that, I’ll probably talk about it once I have understood it well.

My ugly car somehow moving, I then replaced it with a model I created in 2007 for the game Trackmania United, a Peugeot 504 Rally. I’m glad I kept the model, and the import as a FBX file worked pretty neatly.
I wanted it to move only on the xy axis. I edited the code to deactivate the front wheels rotation, and found the way to have the car not to move on the z axis, which in other terms means that the car cannot rotate on the y nor the x axis, and cannot move along the z axis. Which gives the feeling that it is a 2D gameplay, with 3D physics.

You’ll have perhaps noticed that what I checked doesn’t match what I wrote above. That’s because the axis on my car are oriented the “Unity way”, as there is no way to edit them. And when creating the wheel colliders, the orientation has to suit the engine, or else the wheels will rotate along the wrong axis. A bit crazy for a 2020 software. So in my case, the x and z axis were switched, which doesn’t change anything about the principle, it’s simply relative.

It wasn’t too bad, but far from satisfactory, the car’s behavior not being what one would expect. I didn’t bother too much, as I learned a few things, and decided to move on the 2D physics, to see how different it’d be.

One last thing before going: I was super disappointed to see that the collision boxes, called “Box/Mesh/etc. Collider” depending on your use, are still made that way and extremely limited in polygons count. That’s the green lines you can see all around the car, and they are used to “calculate” the physical limits of the objects. Why am I disappointed, you ask? Because that was the exact same thing more than 10 years ago! (for example I witnessed it in Trackmania United)
In 2020, I was really expecting huge improvements about collision detection on a polygonal level, and reading excuses such as “a more detailed collision mesh will decrease performance” is a total no-no to me.

To be continued in the next post

Leave a Reply