Game development studying Whole by Maxim Zavadskiy: Game Programming Basics 2 : 3rd - Debugging using MonoDevelop

3rd - Debugging using MonoDevelop

Posted by Maxim Zavadskiy on 31 December 2011, 11:00 AM


11:00 a.m.


This week's topic should be useful in my opinion although I have experience in debugging. Anyway in case of scripts and Unity things should be different a bit. Let's start from the lecture as always!

How to find bugs?: In my opinion and experience a debuggin on paper is maybe the most effective way although it consumes more time that e.g. debugging using a debugger because you have to e.g. update the variables on the paper each time manually and the debugger does it in your place. But nice thing about paper debugging is that you are acting as an interpretator so you feel some kind of total control on your program which is cool:) Also for me many logic problem are solved much more easily with this method.

I used debuggers quite many times but an embarassing thing is that I always was lazy to study info about some features, e.g. breakpoints! I knew only those that are intuitively clear how to use. But now at last I will learn a bit more I hope. Instead of breakpoints I always used run to the cursor but now I see it's quite manual way of debugging and it might be more convenient to set breakpoints in needed places rather that switch through sources and click a mouse each time.

What are tracepoints?: Well maybe useful thing sometimes instead of incode tracing but that has some disadvantages. For example unlike incode tracing( and debugging in general) I don't thing that tracepoints and traces can be so easily ported to another debugging tool if nessasary or goven to another programmer. So currently I preffer incode tracing. But it would be nice if IDE's would generate trace code automatically and there would be an option t hide debugging code when needed.(I have never used or met such features).

11:22 a.m.


It would be good to hear how debugers work actually. Maybe it is not that easy but I think we have to know at lease the basic principle.

From the lecture I didn't get what is the difference between soft and hard debugging and GDB, what are their pros and cons. Seems I should look into the Web for that. It also was a bit frustrating for me that it wasn't explained why we should use soft debugger and mono develop in most cases. I always like to understand what things I am doing and why.

Ok from the lecture I got a couple of new things such as breakpoint. Sadly tracepoint were not demonstrated at all:(. Not that advanced level I expected. Also I in the video tutorial of debugging and in my experience I see that it's more than frequently needed to step BACK. The fact that I haven't met this shows that this feature is hard to be done. But it would be really needed feature.

I will skip debugging excersises for now as I find them quite boring and not useful for me and will go to "candy" - developing the game futher.


Lets start things!

First of all I will do the remained task from previous week on joining wheels and box.



Ok, seems like a hinge joint is appropriate solution. Joints are useful but... it is a physical cheat to be honest. I wonder, is it possible to create a real joint which consist of physical objects completely. Then it will better simulate the real world I suppose. But proably perfomance will be decreased.

It's not that easy I see to get things work. I had to put 4 wheels but they are behaving like non-physical objects: they are ingoring collision with platforms! I don't know what is wrong. I have to look at reference answers for assistance...

Hm... Joints are not used there! Interesting... Aha! There are box and wheel colliders attached but they are not rigid bodies - that's the solution. Ok..

Now I will start the 2nd task.

I used our previous version of the project (the result of working on 2nd module) as a base. I noticed that it is quite hard to pull the cart on the moving platform because of it's small size and because it doen't stop at the bottom. So I resized the platform but I didn't touch the moving behaviour because it's even more interesting I think in this way. But the cart being placed on the platform behaves like it is too light, it is loosing it's balance and rotating. I tweaked many params of the cart but it is still bouncing.

Ok after some tweaking I get desired results. Now I have to "Make it possible to load the ship fuel."



I found a ShipFuelTrigger already done from solution of second week but I will do my own script.

I found an interesting thing in Unity: actually there're classes for Colliders, GameObjects! And I though it is hidden in Unity engine and we can only manage these objects though Unity IDE!



I studied GUI basics of Unity from the manual. Things are strange for me. I used GUI systems in Software in other way, there aren't OnGui stuff and GUI.smth to create smth. I don't understand why e.g. we have to redraw the button each time with OnGui, event based system I think is more elegant. But I see there's no way but only one in Unity(at least in non-Pro version:)).

Ok after some time I the button "Load Fuel" is desplayed each time the fuel is near the ship and the fuel destroyed when the button is pressed . Here is an interesting issue: where to put trigger script in the spaceship ot in the fuel?? I decided to put in the fuel for Fuel should know how to destroy itself and explose.




Now I need to make an explosion animation when the fuel is loaded into the spaceship.

After about an hour I did my very own(except textures) explosion using particle systems. Now I should make it instaniated when fuel is loaded.



I decided to make the game fair, i.e. the player won't be able to enter the ship if the fuel is not loaded. So I have to make a fuel_loaded member variable for the Ship. And that may be a bit challenging for I don't have Spaceship class but a set of scripts attached to Spaceship game object. For simplity I will add the entering script to the spaceship not to the Lerpz so I can easily access fuel_loaded.

I noticed that altough MonoBehaviour has OnTriggerEnter method, when I begin to type this in the script, the IDE don't suggest to fill the name of the method to the end, which is a bit frustrating.

I found another disadvantage of not creating separate class for each new GameObject(Ship, Lerpz) - when we want to call some method of other game objects we have to use this nasty CallMethod method which is not a good solution.



Some difficulty I met when I was finding out how to detected that the collider in OnTriggerEnter is Lerpz. When I checked that colloder==lerpz it doesn't work because actually the footEffects is the trigger of Lerpz. I am sure that there should be more convenent way than passing footEffects as a parameter to the script but I don't know which way.

foorEffect turned out to works badly so I added separate tigger area to lerpz.

I have a problem hiding/destroying lerpz. When I set active=false the lerpz remains. But GameObject.destroy works! But there's a hidden problem: it will destroy the lerpz not hide it so it's at first chating because the lerpz actually should be inside the spaceship, and at second all the members variables of lerpz will be missed, e.g. it's coins, experience or whatever. But for this time I will do in this stupid way of destroyin the lerpz.

Wohoo! I did it: the lerpz now can enter the ship when the fuel is loaded and I can control the ship but there's a problem with camera: it remains at the same point and not follows the spaceship.

I found a method in CameraScrolling script of main camera but to coall it with CallMethod I have to pass 2 parameters which is not possible it seems. That's another problems with separate scripts. So it seems I have to use default value in that function. But no! There's an overloaded method with one param there so np. OH! CallMethod doen't support overloaded methods! No way but to put there a renamed method.

Fine I did that! Now the last thing remains..

I haven't finished the task today and missed the deadline but I think it is no problem if I sent it to the teacher tomorrow because of holiadays. So no rush..

Wow I'm spending a significant but enjoyable amount of the time on this course, especially on this task!




I used a rotating particle system as an appearance of teleport: looks flne! But I don't know what effect to use when the ship has dissapeared. After a while I decided that the teleport will get smaller and smaller and then a blue explosion will be shown.

Hm, strange! When I copy-paste the explosion from fuel and change it's appearance that of fuel is changed also in the same way! Crazy!

At last! I found an issue: particles! I used in both cases flam particle and when I channged the color in particle system I actually changed the flame itself!

Yep, fine! Now "Quit application after ship has disappeared and final effect has been shown." I think it's not difficult:)



But not that easy because there aren't event's in Unity!!(it seems) So I ended up with this:

if(final_explosion_instance==null&&explosion_beginned) //the game ends after final exposion is gone

which is not beatiful

As for me there may be much better script support in Unity.



Fine I tested the game and all works!


I am attaching some screens demonstrating what I finally did in the task. Enjoy!


Totally I spent about 1080 minutes on this week, that's about 18 hours(if I didn't confuse my calculations)! I can't say of course that I was fully concetrated on the task at all times, so real time may be less.

For that time, I got a good portion of knowledge and experience about Unity and scripting. I began to understand how the whole consept of this game engine. Some things about scripting possibilities in Unity make me a bit disappointed, such as some OOP issues and invconvinces, SendMessage, no Event/callback support. But probably I simply didn't find out how to do all I wnat in Unity in the way I want. Anyway I find Unity quite a powerful and easy to study.

One important things about Unity classes structre I get is that properties of game object in Unity is not done by inheritance but with aggregation. E.g. if we make a gameobject a rigidbody  then the relevant GameObject fiels called rigidBody gets "filled" with RigidBody instance. I can't say for sure at this moment that inheritance would be better solution but I think that personally for me it would be more intuitive.


Attached files Attachments 7

0.bmp (3.8M) - Download

1.bmp (3.8M) - Download

2.bmp (3.8M) - Download

3.bmp (3.8M) - Download

4.bmp (3.8M) - Download

5.bmp (3.8M) - Download

6.bmp (3.8M) - Download


anonymous profile picture
Laurel Kase
On the off chance that there are any regular record types that diverse IDEs will open, the last one introduced will ordinarily be the one propelled when you double tap on that document type. I don't regularly begin an IDE that way (intentionally, in any case.) If you dispatch the IDE from a symbol and keep your ventures for that IDE separate from other undertaking records for different IDEs, at that point you shouldn't have issues.
anonymous profile picture
Quran academy online
We are innovative so we teach online and offer you the best learning practic.
anonymous profile picture
This writing service will save your precious college time and guarantee you exceptional grades. You can use some of your time for more important things like part-time jobs, your family and friends.
anonymous profile picture

Many thanks! An abundance of advice.

<a href="">canadian pharcharmy</a>
online pharmacy no prescription needed -

<a href=>online rx pharmacy Mt</a> 9f70cb8
anonymous profile picture
Controversial issues are all about raising ethic and political questions that influence the general public, and can have more effect in some societies or countries than in others that can de discussed in your essays
anonymous profile picture

Good. I really like this, I just found out about this. This was an incredibly wonderful article.
anonymous profile picture
Pepito My Friend
I've been following and reading your contents for weeks, and all I can say is thank you for this wonderful tutorials. I have learned many things just by reading your articles and posts.
anonymous profile picture
ISO 9001 Certification in Saudi Arabia
This is one of the finest post i have ever seen. The information is genuine and relatable . We are really grateful for your blog post.
anonymous profile picture
best online pharmacy
<a href="">best 10 online pharmacies</a>
<a href=>canadian pharmacies that ship to us</a>