Thursday, 23 October 2014

Moments of frustration! What the hell am I supposed to do?!

Oh dear...

Just started to continue my racing game project. Finally I found some great setups for wheel colliders. Even without coding, it worked pretty well, but using some codes to dynamically edit the friction values of the wheel colliders could do some wonderful things. BUT!

Everything went way too nicely. Dark clouds gathered over my head... It was the calm before storm... After happily playing with the car and break some record lap times I decided to use the fake anti-aliasing script. It doesn't work in the editor for some reason. I mean the reason is that v-sync doesn't work, so it can't run with fixed 60 FPS. So I decided to build a webplayer version. It has been started. The great work. My creature... my child... my new experiment... I was so excited!

After some long second... it was born! I had to check it out. I started to run the webplayer build locally and... something went wrong! What happened to it?! Why did that happened?! WHY?!

It was horrible. A horrible, distorted creature. Two wheels were missing. No, not just that. Even its chassis wasn't there. How could it happen? Calm down... calm down... I told myself.

Let's go back to Unity editor. Nothing can be wrong, right? It must be a problem with the web player build. I was sure about it. I had similar problem back then, when in the editor, everything was perfect, but in the WebPlayer build something was wrong. Something was wrong... something was wrong! Even in the editor! I... I was confused... I am confused! It was working perfectly before!

I saw errors. Failures. I don't know why? What happened, what changed. I tried different things to fix it, but I don't really know, what's the problem?

!CompareApproximately (SqrMagnitude (q), 1.0F)
UnityEngine.Quaternion:Euler(Single, Single, Single)


transform.rotation assign attempt for 'WheelFR' is not valid. Input rotation is { NaN, NaN, NaN, NaN }.
UnityEngine.Transform:set_rotation(Quaternion)


What? Why?! It's at the two wheels. But I didn't change a thing at the coding part and they use the same code. So what's the difference? What don't they work as the other wheels? Oh, anyway, all the wheels and the chassis are at place. So it's different than the webplayer build. But the result is still the same.

Other error, when WheelColliders reach the road.

transform.position assign attempt for 'GenericCar' is not valid. Input position is { NaN, NaN, NaN }.

Not A Number... REALLY?! WHY! I read about that division by 0 can cause this, but I don't do that. As far as I know. Where the errors point, there is no division. Can it be because of a glitch in Unity 4.6 beta? I updated to the latest beta and it still doesn't work... *sigh*

I am confused. The creature I created is a failure. It's not complete. It's abnormal. It's an anomaly... What am I supposed to do?!

Wednesday, 15 October 2014

Cheapest anti-aliasing ever!

Did you play Gran Turismo on PSP? If yes, you may know, that games uses a very simple, efficient, and acceptable quality anti-aliasing method. What does it do exactly? It moves the camera in every second frame one pixel right and up. That's it!

Friday, 29 August 2014

Papercraft quest begins! Making Ferrari F14T!

I want to try out something different. I was always interested in origami and other papery things. I did a lot of Origami in my childhood which was fun. Now I want to make some papercraft! Combining my 3ds max knowledge I want to turn a 3d model into a tangible product. I never did something before. I mean I neved did papercraft before, just origami.

I started to work on my model and I started to study the program called Pepakura Designer. It's a program that can turn 3d models to papercraft templates. Very effective and easy to use. But I have no idea, what kind of paper will I need, how to glue the parts, how to print the parts on a stronger paper. Hopefully, I'll get help. Until that, let's see the model. Here is the current progress (the modelling is almost finished):

F14T Papercraft
F14T - the beginning. Looks like a wierd vacuum cleaner... or a fly's head... fly's head? Really?


In Pepakura Designer

Finally, tyre texture!
Accuracy won't be perfect. I don't have perfect, good resolution reference images, and most of them are photos with perspective distortion, they are not 2D blueprints.

Thursday, 21 August 2014

Double dilemma! Realism or fun? More details or simpler graphics?

As the title says. Double dilemma. What should I do? Make a game which is closer to realistic in term of physics or make it simpler but easier to play. Also what about the graphics? I tried out different approaches for making it nice and cartoonish, but which method is the best? Let's find it out!

New physics test!

Physics are getting better and better, but it's still very far from my expectations. I still think my tests were successful, however I'll probably rewrite the code that controls traction. As you can see in the video, the traction is low at low speeds and the car slips easily, but I need more slip. Actually it's pretty stable even when I push the pedal to the metal. A real world car like this would spin immediately in this situation from standing position.

Monday, 11 August 2014

Back from holiday...

I am back from a great holiday, it's time to get back to work on the project... and some other things. But let's talk about the project only. I have a car, a track in progress and a playable private apk file with configurable touch and tilt controls.

What should I improve? Well, the physics are pretty simple now, I need to program the tyre physics into a way more realistic one. Well, by realistic I mean still arcade, but more believable. Once I made burnouts, but it was poorly programmed, I need to upgrade it. It'll be good on a mobile device. Tapping the accelerator will be a good way to keep the car stable without spinning out in a slow corner. Maybe I'll use animation curves for setting up the tyre friction for different situations. Also I am thinking to make an indicatior that shows how much the pedals are pressed over the touch area. So the player could "feel" the pedals more. Of course it would be optional, but a helpful thing.

Maybe I won't release more public webplayer demo, because the controls are not really good of keyboard. Or if I will, I have to program a better keyboard control with speed sensitive turning like rFactor has.

That's all for today, I am planning to make a great progress in the following week.

Friday, 1 August 2014

Working on the background...

I don't usually share only one picture, but when I do, it shows some improvement in graphics.

 Unity Android Racing Game
Hand-drawn background just made overall look better.


Tuesday, 29 July 2014

Trigger based occlusion culling

Upgraded trigger based occlusion culling script is almost done. Good alternative to Unity Pro's Umbra Occlusion Culling system.

It works, just it needs more testing. It works pretty well using any cameras on the scene. It needs some manual work, setting up the trigger. select the game objects to hide, but now, it works with children too, so it's not needed to put all the objects one-by-one if they are parented. So the workflow is way faster than before. Combined with the basic frustum culling, it is a pretty good way to keep the triangle / draw call count low.

Also clever level design is important too. Placing objects that can cover other things can help a lot with the combination of this script.

Occlusion Culling in Unity Free
Occluders

The pit lane is not ready yet on the current track I am creating, but garages and other buildings will be really good to cover a lot of other things.

Occlusion Culling in Unity Free
Two of the tribunes and some trees are hidden as they are not needed to be visible.

Unity free trigger based occlusion culling
It's that simple. Make a game object with trigger collider, place the culling script, set it to Occluder layer and it should work. Main camera needs an other object with kinematic rigidbody, which copies the camera position and when that enters the occluder, it'll hide the given game objects or game objects' children. Easy to setup and works pretty well. just good positioning of the occluder is important.

Monday, 21 July 2014

Low-poly tribune with fans

Low-poly tribune


Tribune design for old school Formula 1 style racing game for Android. I overall, it currently has 6 textures including all ad boards and fans. Stairs are flat, and the whole object consists of 570 triangles. I made a low poly man character in 3ds max which is less than 500 triangles. I made different textures and poses for it, and rendered as texture. I'll make more with different cloth style also I'll need female fans too! 

Sunday, 29 June 2014

Facebook - Racing game photo album

I made some little progress on the racing game project for Android. Here is the current screenshot album on Facebook. For more, please like my Facebook page!

Tuesday, 11 March 2014

Simple iframe for Unity Webplayer (with instructions and download)

I made an easy way to embed Unity games into websites. Download link: https://dl.dropboxusercontent.com/u/85819592/Unity/SimpleFullFillTemplate.zip
(Extract the WebPlayerTemplates folder into your project's assets folder and select the template at Edit->Project Settings->Player)

To use it with iframe, put this into your html / php's <body>:

<iframe height="95%" src="your_webplayer_url/webplayer.html" width="100%" ></iframe>

Also works with any CMS. In some situation, you should modify the height to a fixed value in your webplayer html and in the iframe too. If you want to get rid of the default iframe border, use this attribute: frameBorder="0"

The following example is sized to 700px high. The reason is just because it is embedded at an other site where this size was set.

Racing game? It'll be done!

I started a racing game back then, but I didn't make any progress in the last months. It doesn't mean, I forgot about it or I gave it up! I was working on that Flappy Bird clone. Also I had problems with the car physics.

James Hunt McLaren M23
A pretty old screenshot...
Good news, I found a pretty good way to make the cars work with the wheel collider component of Unity. It will be a little bit arcade style, but also it'll be fun. And it will be pretty stable at high speeds too. Nothing to worry about!

James Hunt McLaren M23
...and a newer one.


Also I'll make the tracks low poly, but detailed. It'll work on PC and Android too. What I learnt from my Flappy Bird project is handling MySQL databases through Unity. I think it'll be a useful thing for online lap time comparison.

Friday, 7 March 2014

My first game!

Do you know Flappy Bird? Maybe you are one of the unlucky persons who knows that game. And guess what? I made a Flappy Bird clone. There are hundreds of them! And I made one too. The main character is an F1 driver who jumps out from his smoking car. Probably you know who I am talking about. That photo of him was a great target of Photoshoppers. And a good target of me to create a game of it.

Click on the image to start the game!

It's not 100% finished, I need to fix some things, but it's working. Final version is coming soon! You can play it here: https://apps.facebook.com/flappymax/


Saturday, 22 February 2014

[Game Review] - Pixel Dungeon (Android)

Pixel Dungeon - an addictive rogue-like experience

Platform: Android
Developer: Watabou
Genre: RPG, Rogue-like
Date of release: 2013 (usually updated with new contents!)

Back then there was a game called Rogue. Released in 1980, it was a dungeon crawler game with random dungeon generation, released on multiple platforms. It used a non-graphical (character based) terminal interface, so there was not even pixel art graphics back then. The player could get items, fight monsters, and go deeper in the dark and dangerous dungeons. There are tons of rogue-like games, and Pixel Dungeon is one of them.
Pixel Dungeon title screen
Title screen and menu (I took the screenshots from BlueStacks App Player, yes, you can play it on PC too, it works without any issues!)

Monday, 17 February 2014

Adam Jones and the wheel colliders of doom

Wheel colliders... my enemies... or is it? I tried to use them for my racing game, I was sure they will be great. Well, they are great but they need to be properly used. And it's not easy to set them up correctly.

First problem: car goes left or right without steering on a plane ground. It's a common problem as far as I know. I read about on forums and some say it's a bug, other say it's because of incorrect settings. Honestly I don't know, which one is the truth, because as I made experiments with it, some settings were even worse, some of them were almost good... just almost. It still went left or right. I actually found a gif on Unity Forum, which tells me, it's a bug.

Decreasing fixed timestep removes the drift effect, image uploaded to Unity Forum by bitbutter 
It's a serious issue, especially at high speeds! Actually,  I couldn't fix it. I tried to slow down the outer wheel, but it didn't work. I didn't really make any precise calculations for that so...
It's frustrating. I really don't want to make my own wheel collider. Maybe I could do it, but I never tried. Actually, there is a good raycast based wheel collider in Unity Car Tutorial, which I mentioned in previous posts, but they are slow on mobile, however, the suspension system can be useful from that code.

Second problem: finding the right setup is never easy. In case of the custom Pacejka formula based custom collider which comes with Unity Car Tutorial, it was really easy to set up. Hours of tweaking, but I was never far from the right values. It was always enjoyable to drive the car, sometimes it was too easy to drive, sometimes the grip was very low and it made it hard to drive. But it was fun. And at the end I was able to set it up right, just the problem was, this wheel script is slow on mobile platforms.
In case of the Wheel Collider component, I still wasn't able to find the good values. So bad performance vs bad handling... good.

I made a little research and I checked out the Unity Car Tutorial once again because it doesn't have the weird drifting effect and it uses the same wheel colliders! How it's possible? Well, the answer is simple: it doesn't use motorTorque, which means, the car is not powered by the wheels. It's more like a force pushes the car, because exactly that is happening! It uses forces instead of torque, even for braking. Also for turning, it doesn't turn the wheel colliders, but uses rotate.around to rotate the car around a point based on some simple calculations. I must say, these are cool tricks, but mainly for arcade style racing games. In this case, if you want drifting and making doughnuts, it's more about good scripting than pure physics.

I think, I need to go deeper about this topic, because those wheel colliders are the doom for me. Like some untameable animals. They are there, they are useful, but hard to use properly. Or should I make my own custom wheel which is fast even on mobile?

Actually, old games make me think. There is my favourite NFS title, Need For Speed - Porsche Unleashed (also known as Porsche 2000). which is a fairly old game, came out in 2000, and it had a nice, semi-arcade handling. It was running on a 200MHz CPU, a little bit more powerful was recommended, but it ran. I think maybe 6 or 8 cars could race at once. I don't know how it was programmed, but it worked well. Or I should mention earlier F1 titles. That's cool, how they achieved pretty good physics with simple calculations.
Note: old games rock!

TO BE CONTINUED...

Saturday, 1 February 2014

Burning some rubber.

And an other test is here! I was playing with the tyre friction values of Unity's built in collider. Damn, it's hard to setup properly, but I'm on the right path to get what I want. This time, there is sound too.

 A video of a very early progress:


Friday, 31 January 2014

First video of the project

Hello there! Here is my first video of my game. It's a very early progress, I am currently working on the physics. As you can see, it's far from perfect. I didn't program the engine, and gears, also the traction needs more programming. I'll be back with more videos soon! Enjoy!


Friday, 24 January 2014

Painting!

Flat, white colors with shading... is it looking good? NO! It's not. So, I tried to paint it. I'm not good at unwrapping a model, but I tried my best. Well, the result it not perfect, but I learnt from it. I usually use Photoshop for things like this, but this time, I gave a chance to InkScape, a vector graphic SVG editor. And guess what? It did its job very well!

Monday, 20 January 2014

LOD

Nope, it's not Lord of Destruction... Of course, I meant level of detail in the title. Currently I am testing a simple LOD system (for Unity Free) based on the one I found on Unity forums (Thanks to Westmark). I already made some modifications on it. I disable game objects with it which contains the meshes (instead of changing the mesh within the mesh renderer component). Also I'll make it more versatile, it'll be possible to set the distances for each details instead of the current system. Working well, but I have no idea about the memory usage yet. All the details have to be on the scene, but in a disabled state. So they are preloaded.

I am targetting mobile devices and mobiles / tablets has usually small screen and / or low resolution. Small screen / low resolution means, you can't see everything in a high detail. So it is possible to make the lower detail models much lower than on PC. Wheels will be very angular in the lowest detail, however they'll be detailed in highest detail and cockpit view. Probably the most simple car model will be around 500-600 triangles, the highest detail will be around 2500-3000 (tyres and driver included). I have no performance data yet, but I think, this LOD script is efficient.

Wednesday, 15 January 2014

Tuesday, 14 January 2014

Friday, 10 January 2014

Let the coding horror begin!

Hello people of internet!

This is my post about my game development progress. Well, I am trying to make a racing game for Android. My main development tool is Unity (the free version). I am still new to mobile game development. It's a little bit different than making games for PC or other high performance consoles. Mobile devices are still not as fast as desktop computers. Both GPU and CPU are weaker, some devices has low amount of RAM and storage. So it is limited and developers have to be very clever at optimizing games.

Profiling is not very easy without Unity Pro's profiler, but I found a great solution called Adreno Profiler which doesn't work on all the mobiles, but it runs with my Nexus 7 2nd Generation. So finally, I have a profiler, I can see, what costs more or less in rendering, so I can tweak my game and test again and again. It's a great tool, and easy to use. Well, this program quickly gave me ideas, how to make graphical performance higher. However, I didn't find out, how to check CPU usage in it. I have a simple CPU usage monitor on my Android device, but I can't figure out, what are the most expensive calculations.

Adreno Profiler
A great method to figure out, where is your graphics bottle-necking.

Actually, I have a serious problem. My game is greatly bottleneck at physics I think. I'm not sure, but the more the cars the less the performance. I mean seriously, I put 4-6 more cars, and FPS decreases. It's not good, especially talking about a Nexus 7 which has a decent hardware. I tried out making the car meshes more simple (I just used a simple box), same problem, so the problem is not graphical, but more like the calculations are too much for Qualcomm's Snapdragon S4 Pro CPU. Very disappointing, I need to find an other was for physics, I guess. Actually, I was very happy with the current physics.

Adreno Profiler Graphs

Don't know, what to do now... Well, I need to figure out, what is the exact reason for the bad performance. I need to simplify the physics as much as possible without making it very unrealistic and bad. More experiments tomorrow. For today, I am out!