Looking for those darn bugs

Here is a clip of a small problem I had last week. It seems that when I killed my opponent my health immediately went to zero and I died as well. Here you can see I manually change the health of the opponent, he/she dies and poof so do I. Funny looking but not so funny when I could not find the bug.

Bug hunting is now over. I spent most of the day at work looking for this illusive critter and only after I went home, moved scripts around and segregated most of the code I finally found the problem. As it turned out, if I had taken the time to investigate at work like I had time at home I would not have had to do all the changes I did (but the code is nicer for it). All that had to be done was add the following to the condition of an if statement “&& !enemyController.dead”.

Below is the problem I experienced.

Visual Studio

I have spend most all of my free time getting back into programming in a big way and enjoying it more than I ever did in high school. It does amaze me how concepts I learned more than 30 years ago seem to come back in bunches now. This weekend I had created some methods in some very different ways than my instructors were doing, knowing inside that my way would work very well but had hit a road block with my code. I walked away for an hour or so and my brain went into overdrive in the background while I was thinking of others things. Thinking I had not been in Blender for a while and needed to get back with some modeling. As soon as I sat down to continue where I had left off I had the solution at my finger tips and it worked wonderfully. Now it is time to start documenting all of these coding snippets on YouTube or some other type of note taking application. Maybe I’ll start using OneNote on my Surface which should sync with all of my devices.

Never Happy

I am recreating the RPG, Diablo style game I have been working on. I decided last week and this weekend that the way I have been creating my scripts or rather the way I have been organizing my scripts was not the best was and that I could do a much better job of organization than I have been. For the most part it has everything to do with not placing as many methods within a single script which in the end, so far seems to be limiting the use of the GetComponent and GameObject.Find. The way I had things organized the use of these methods I felt was over the top. As it stands now, for the most part they are called once in the awake method to initialize the references and rarely again. I’m hoping this will help keep my code from hindering the frame rates. We will see.

On the Unity update front, it seems all is well now and I am not being asked to log in every dang time I start the program, good things on that front. 🙂