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…

Leave a Reply

Your email address will not be published. Required fields are marked *