AI for Unity game development, my experiences

Peter:

What's up, everybody? Welcome to a new episode of the UI Buzz podcast or video cast if you're watching the video. So it's been a while, but I have been working hard, very hard in fact, on my project hack game that you can see on the screen here if you're watching the video. And I want to talk a little bit about using AI tools for game development and how it has both helped me and hurt me bad. So what am I talking about here?

Peter:

I've been working on this for a long time. This is my project hack, idle, numbers game. If you're into that kind of thing, you'll know what this is. But in there is a feature, right, that I wanted to add. Now, I wanted to have multiplayer support.

Peter:

To do that, I decided to use Unity game services. I've tried a few different ones, and this is all part and parcel of the problems that I've been having. So I turned to AI tools. And what I needed them to do is solve the problem for me of the game save and storing that in the cloud, syncing it back and so on. I know how to do local game saves in Unity, not a big deal, done that before.

Peter:

But the idea of doing the local save, uploading that to the cloud, having that come down from the cloud and so on, and all of the parts wrapped around that logic have been a nightmare for me. And everything I've tried worked by itself. Then when I bring all the parts together, it didn't. This was a prime time to say, AI, help me out here. So I have a Claude code subscription and I tried using that.

Peter:

Claude code has been very good for me on many different projects, not for game development. So I was like, alright, here's a chance to shine. Because under the hood, we're just talking about C code. That's all we're talking about here. The problem became, it would work to a certain point.

Peter:

And then there's like a tipping point where it would just fall apart and become horrible. And what I mean by that is, let me give you an example. I'm going to walk you through this, right? So I have this register part, which worked great. It helped me write the code to just take advantage of Unity services to have a new player register with the Unity backend.

Peter:

And the same with the login. I made some screens and it logged in and it was great. You can see where it's username, password, and login, and these are just controls that I put on the screen, forgot password. And then for the registration, similar thing. Layout is not very good here right now, but you get the idea.

Peter:

Password, confirm password. Claude code was great at handling all of that, including the form validations, does the password match and the confirm password and so on. However, the problem became when I started to have it work with actual game data. And the reason for that is because this is an idle game, I'm using a large numbers library quadrillions, trillions, millions, billions, septillions, all that kind of thing. And the way that works is there's a coefficient and a magnitude, right?

Peter:

So it's essentially two variables in one is the way to describe that. And it displays them on the screen. Fantastic. Everything works great here. But when it came to having Claude code understand that library, it did.

Peter:

But when it stored the data, it didn't really store it right. And it sure as hell could not figure out how to upload it to the Unity game services for the cloud. And I was like, Okay. So it got me that far. And then like I say, it didn't.

Peter:

So I had heard about this other tool on a video on YouTube. And this other tool is called bezi.com. What it is, it's two parts. It is a desktop application that you use to interact with it. And then there is a plugin for Unity that allows the app to work with Unity, right?

Peter:

And there's two ways it works. Number one, you can ask it questions like you would any other AI kind of tool. And it will give you recommendations, tell you what to do, how to do it, where to go, and so on, and walk you through it. The other one is it will do it for you. Now, what that means is it will actually make those changes for you in Unity.

Peter:

It will actually interact with Unity for you. And not just the code, but the UI stuff as well. So go over to the website and check it out. It's what they call the agent mode. And I was really skeptical because, like I say, I clawed code, chat GPT, it had just not been working great.

Peter:

I was like, oh, okay. Is this really gonna work? Well, Bessie worked fantastically well. Let's just cut to the chase. I was blown away by how good it was.

Peter:

And what it did, I'm going to show you the tool here, I'm going to show you some of the conversations I had with it. For example, I said, hey, I have a scene called Main Menu. And I said, look, I got these buttons. And I want you to create the code for all the Unity services for registration, for forgot password, and for playing the game, and so on. And I also set to it, when the player is logged in, the register and login buttons should be disabled.

Peter:

And then later on, I did change it to say hide them, and just show me the play button, but show me a logout button, and vice versa. So I gave it all of that conversation. I'll just go through very quickly. It went through in the project. Because of that plugin with Unity, it found all of my files.

Peter:

It created some new files for player management, like player login manager and so on. And you can interact with this. Like I say, I had it do it for me, because I really wanted to test this. But you can have it give you the instructions and then follow it, right? So it went through, we found all these things, and it shows you this is what I'm going to do.

Peter:

In this case, I checked the bug to say, go ahead and do it. So it created the files and so on. Then it'll give you setup instructions. And it'll say, hey, over in Unity now, create this new game object, or this game object now exists, depending on how you have it do it, and drag the UI controls to the appropriate serialized fields. If you're in Unity, you know what that is.

Peter:

So I've got this SceneManager here, and you can see, look, it created this main menu manager, and it created all of this UI for me. It basically said, look, hey, drag this login button over here and drop it in there and so on, with all the other UI parts. And also, hey, I see you have these scenes. Does this look right? Yes, it did.

Peter:

And that was it. Other than setting up the Unity service in the cloud like you normally would, the C code it wrote, the classes, they just worked. I was super impressed. And I think the reason it's better with this tool and tools like this than just generic code helping tools is because it is specifically targeting Unity. In other words, look, Unity, C.

Peter:

Don't scour the web or anything else related to other things and confuse yourself with AI tool. Just focus on Unity, C. That's your options. And so it looks at the Unity documentation, doesn't look outside of that, all those kinds of things. And I think that targeting made all the difference.

Peter:

So like I say, there's this main menu, manage a script here, you can see off to the side, it created all of this for me. I did have to tweak a few things for some things that I got wrong when I was thinking about what I wanted it to do. But it solved the problem. And then later on, after that, I was like, okay, my next big problem is now I need you to deal with the game data. And I was concerned, and this is where I expected it to fail.

Peter:

Because I expected it to say, uh-oh, we've got these large numbers that go here. I'm just going to run the game so you can see this running here, if you're watching the video. But we've got these large numbers, right, and I expected it to fall apart. It didn't, is the answer. If you're watching the video, I'm going to go over and I'm going to say, okay, I'm going to set a large number.

Peter:

Just so for those of you who don't know what I'm talking about, they're large numbers. Right? I'm going to set the magnitude to five. So here you go, 918. If you're watching the video, that's a big number.

Peter:

It's a big number if you're not watching the video. But the point is, it needed to understand all of this data. And bezee nailed it. It looked at the source code for the large number library that I was an asset, and it nailed it. And it's, hey, I got this.

Peter:

I understand this now. Let me create you again a manager to save this game data from this object, this player data game object. And I see you've got the script. Let me save all of this for you to a local file, and then upload it to the cloud, because that is what you asked me to do. And it worked.

Peter:

And I was super impressed. And I was like, okay, so we continued the conversation. And I said, all right, now I need you to load that game data back again. But here's your edge cases. If the game data file doesn't exist in the cloud, or you cannot talk to the cloud, I want you to use the local save as your backup.

Peter:

Load that data instead. And if the user is not logged in, again, do the same thing. I gave it all of the scenarios that I or you would naturally think of as your developer and working through these. And again, it understood it, and it did it, and it nailed it. There was a couple of compile errors where it was just using something that wasn't quite right.

Peter:

It was some old scripting. It was basically a bit of old documentation. It's given it the old way. And I said, look, this is the old way. I want you to do it the new way.

Peter:

It thought about it again. It updated it, it worked. And then I want you to do the cloud save every one minute. And it said, hey, you know what? We can do better than that.

Peter:

How about we give you the ability to set it however you want it? So what it does is not only does it save it, but not only does it upload it at the schedule that I asked for, but it also gave me a menu option to say, hey, why don't I give you a UI that says if you want to change this on the fly, you can just do this in the Unity UI. And you can see these checkboxes if you're watching the video. It also said, hey, why don't I give you some extras while I'm at it? I'll give you an enable and disable for auto save, load on wake, enable the cloud save, prioritize cloud on load, which is the one I talked about, and encrypt it.

Peter:

And the darn thing worked. I was just blown away by how good it was. The takeaway from this episode here in this video is try a few different tools, find what works for you. But for me, this solved a problem I had been trying to solve for months with, firstly, my lack of understanding, and then my lack of understanding plus ChatGPT and then Claude code, and we all confused each other, no end, and worked and then fell apart. But Bessie, so far, shout out to them, I'm using the free version right now.

Peter:

But I think the first plan is like $20 a month. If you're a serious game developer, I can't express to you how much pain and aggravation and months of coding. This has solved for me, and it worked. Just wanted to put that out in this episode. There are some great tools out there for game developers.

Peter:

Use them as assistants is my advice, right? So all the code that it wrote, I reviewed. And it gave me the documentation for it and everything else. It solved my problem, and I understood how it solved it, and then manipulated code for things that I needed, that either I felt could be done a different way, or I knew that I would want to use in the future slightly differently. So check it out, folks.

Peter:

But for game developers, not just Unity. These exist for all the other engines and that I'm sure. I have used Claude code very successfully with Godot, for example, strangely enough. It works beautifully for that. Doesn't work so great with Unity.

Peter:

But my point is, if you're a game developer and you're trying to solve a problem, and you just reached that point where you know you've reached the limit of your understanding, and you can't figure it out, give one of these tools a try. Let them see if they can solve the problem, and then learn from those. That's what I got for you in this one. Put a message in the comments. I'd love to hear your thoughts on this.

Peter:

We'll be talking a lot more about my game development stuff, as I'm really into I got past this roadblock now. And obviously, know it's been a long while since the last podcast episode, but don't worry, we're back on it. So that's it, folks. I will see you or speak to you in the next episode.

AI for Unity game development, my experiences
Broadcast by