I like collecting things and avoiding things

So up next on my to do list was to get both a power-up and a hazard working. I figured out the power-up pretty quickly… for the most part. The hazard took a bit more. Specifically, I made a fire which immediately upon entering would start decreasing health at a regular rate (1 unit per second, won’t be the final rate but works for testing) until you exit the fire. Simple enough, in concept, but the OnTriggerEnter2D and OnTriggerExit2D functions were not working *quite* how I thought they would / should work. Specifically OnTriggerEnter2D was triggering multiple times when I entered the fire… I thought it should only be triggering once… and this complicated things a bit. I mostly got it worked out but I feel like it’s kind of questionable code, and it’s not perfect… it still randomly subtracts 3 units of health on entering before going to the regular 1 per second while in the fire. Not sure why. Figuring that out is on my “to do” list, but at least the fire is mostly working as it should be.

I’m still getting some physics interactions that I don’t want with this stuff though, both the power-ups and the hazards are slowing my character down a tad bit / etc. I really don’t want the power-ups to affect my character’s physics at all, they should simply disappear when acquired. And the fire well… IF I decide to make it do something like, for instance, slow down the character a tad bit as he runs through it, I want to control that slowdown rate myself… so I need to figure out where the current physics these objects are placing on my player are coming from so I can scrap them and implement my own at will.

Hmm, what else? I freaked out for a bit when my game started to run uber laggy despite not having much of anything going on yet, worrying that I had a bunch of inefficient code all over, and strictly speaking that was correct. But the inefficiency wasn’t any required code or anything, it was me overusing Debug.Log for testing purposes without realizing how quickly it could destroy performance. I thus learned a very important lesson about not overusing Debug.Log. Removing a bunch of those got everything back in shape fast.

Still, it brought an interesting question to my mind which was… how will I know when performance issues are my code versus my terrible, outdated laptop which sucks to play video games on? I suppose that the more serious I get about game development, the more I will have to really consider buying a brand new computer with decent specs for gaming. Still, I’m making a sprite-based 2D platformer and trying to use minimal physics and all, so hopefully I don’t exceed my current machine’s reach anytime soon.

I was going to get into some theory here but this already ran a bit long so I suppose I will hold that off until next time…

Going back to the fundamentals

Before jumping into Unity 4.3, I honestly had no idea what to expect, since outside of music production I had never done anything related to game development before. I was talking with a (sometime) game developer friend and told him that if I can get a character moving around on screen within 3 to 6 months I’d be happy. Well, it only took about 3 to 6 hours. I’ve worked on a lot of other stuff since then, including entirely redoing the way I was handling movement and collisions… twice… but the fact still remains that I did get him moving pretty quickly. He still needs some work, but I’m content for now. The point is that things are happening much faster than I anticipated, and now I have my character walking and running, double jumping, switching gravity, etc. None of this is animated yet, so he is just kind of sliding around, but hey, the basic mechanics are there.

However, the more that I dug deeper into the (C#) code, the more that I became reminded of the fact that I haven’t actually had much experience with object-oriented programming. I’ve done the majority of my programming in PHP which, yes, is an object-oriented language, but I managed to do it for 13? years while mostly avoiding making my own classes, objects, etc. It seems like this would be a bad way to approach C# development in Unity, so I decided to take a little pause and focus a bit more on figuring out some of the basics of C# and object-oriented programming before pushing the game programming forward. So that is how I have spent the last few days, although I’ve also spent some time on small things such as getting used to the GUI class and such.

I also decided that I should organize better before moving forward, because my one massive Word document wasn’t cutting it, so I signed up for Trello and transferred everything from said document to a more dynamic format that works better for development ideas / issues / etc. It’s not a perfect solution, and it kind of bothers me that I have no way to back up anything I put in there, but it is simple and easy to use, so I’ll roll with it for now.

I think I feel a lot more comfortable moving forward now. Time to get back to making actual game stuff!

PS. I’m only referring to my character as “him” because right now I’m using a Mega Man sprite as a placeholder graphic. Once I add in actual characters I’d like to get gender options if feasible. But I won’t be making the art assets (I’ll be doing everything else, I just suck at art, know your weaknesses and such) so that will be up to the friend from above, an awesome pixel artist who has jumped on board the (loosely defined) project, as well as my girlfriend if she wants to do add in some sweet hand-drawn stuff.

I think I’m making good progress?

On the one hand, I implemented a working double jump on my own, which made me feel smart and stuff. On the other hand, I started at 1 am thinking I could throw it together in an hour or so and instead it took me a bit over 5 hours because I made the poor assumption that my character was actually grounded and “isgrounded” would return true whenever he was, you know, standing on the ground… I found out too late in the process that this was not the case. So I had to throw together a hack to take into account the fact that isgrounded seemed to be in a weird state of near constant flux.

I guess I need to work on my character / platform hit detection and get that nice and tight so important things like whether my character is touching the ground return true consistently before I go much further with everything else because I really don’t want to rely on hacky code. But… my hacky double jump does appear to work as it should so far so yeah, ultimately I consider it a success.