Coding

At first, I thought this blog would be a place to share some of the things I’ve discovered while making games like new code that was hard to find online or my way of solving a problem that I faced. But that didn’t feel right to me. Today, right before I started writing this, I discovered what this blog should be. But before telling you what it is, let's go back to the start of the day.


For reasons unknown to me, I woke up early in the morning (local time: 11:00 AM) and started working on the boss for event one on the game I'm developing, "War of Shapes." I had a problem with the boss not dying when the player was shooting at him. Eventually, I figured out it was because he didn’t have a Rigidbody2D. This didn’t make sense to me because if he had a collider, it should have been fine since the code goes along the lines of "if there is an enemy with the tag 'enemy' and you collide with it, destroy it." But for some reason, it needed a Rigidbody2D. I eventually got that right, which led to other complications, but they weren’t too hard to fix.


After that, I got up from my bed and went to the living room to have breakfast. After some breakfast and a YouTube shorts distraction, I went back to my game to add a couple of features to my boss. This went fairly well. I made him shoot at me and track the player down, which was fun. Then, while playtesting, the joystick kept bothering me. I had been getting complaints from play-testers for a while, so I decided to fix the joystick. I dove into it with the energy I had from fixing the boss, thinking it was going to be easy. Oh, how I was wrong.


To clarify, the problem with the movement joystick was that if you were holding it and moving forward and your hand let go, it would go back to its origin point. You would have to drag it back up again, which could get annoying if you were being chased by enemies. What I wanted to do was make the joystick come to where your finger is. So, as one does, I went to YouTube and searched "good joystick." Lots of videos came up, but none of them felt right. In all honesty, I only opened about three of them and then just went to Google and asked, "how to make a Unity 2D joystick anywhere on the screen." It suggested a video that had the logic I wanted, or at least some of it. I was happy. The explanation made sense, the code made sense, so I implemented it. And, to no one's surprise, it didn’t work. Hufffffffffffffff.


So here I am with code that doesn’t work. I tried AI, I tried a lot of things a lot of things being making AI explain it and redoing it again and again. The problem that arose was I used the new input system for my character movement, which makes it simple, and assigning it to the joystick was even easier with the on-stick script Unity provides. But this easy function was preventing my success. So I was left with a dilemma: should I find new code or should I change my movement system? I decided to try to fix the existing code instead of both alternatives. This led me to realize that if I could apply the on-stick script to a joystick handle, why couldn’t I apply it to the panel that is holding it? Since the panel can fit the entire screen, I can touch anywhere, and it will respond, right? And yes, the answer is yes, it will respond, and my problem is fixed. The joystick works.


Please understand, that when I say those words, it is with hurt because I spent an entire day on this. A whole day for something so easy. I wanted to cry, but all I could do was just laugh, just laugh. So you might have guessed: this is it. This is what I want to write about. I am a beginner in the game development world, and I am bound to make mistakes and encounter bugs that are harder than this. This is what I want to express these moments that make me feel like crying so that this place can be a space where I can vent my frustration and share my somewhat weird journey.


So what I would like to say is usually there is a better and easier way to do something, and you might not always see it. And that is fine. Code is like that.


Comments

  1. Very well put. Your journey through this is inspiring.

    ReplyDelete
  2. " usually there is a better and easier way to do something, and you might not always see it. And that is fine. Code is like that. "
    - bert
    Truer words have never been said. Really inspiring man, keep it up!

    ReplyDelete

Post a Comment

Popular posts from this blog

ABOUT THE BLOG

War Of Shapes