Get Into Git!

I paid tribute to Jim Carrey’s the Grinch this past week. The scene where he sat yelling, “You’re an idiot!” at the Cave, which yelled back at him, “You’re an idiot!” Finally, the Grinch tried yelling, “I’m an idiot!” to which the cave still replied, “You’re an idiot!” The Cave outsmarted him and he knew it immediately. I played the part of the Grinch this week. I completed some good work and my idiocy didn’t erase all of it. PSA, it’s never too early to version control your work!

Consequences of Choice

In They Have a Cave Troll I outlined my overall vision for Odd Jobs, I want an RPG where your choices matter and persist in the world. I thought more about this and realized that ultimately (read not in my first or even second release) I want the game to respond to the character’s personality. I don’t mean a good or evil indicator, the world is more complex than that. If the character interacted with NPCs in a helpful, friendly, or altruistic way then like-minded NPCs would respond in kind. The game would respond by making altruistic tasks easier to accomplish and more meaningful to the player. If the character acted aggressively or selfishly, then like-minded NPCs would still respond in kind, but those same altruistic tasks become harder to accomplish; however, selfish tasks become easier. Like I said, this definitely won’t make it into the game anytime soon as I haven’t fleshed out the concept enough. However, all ideas have to start somewhere. I wrote this down on my Future Features Trello card and I plan to develop the idea over time.

I felt good about my idea when I learned that Larian Studios announced a new game, Divinity: Fallen Heroes. I heard about it from their Original Sin 2 update on Kickstarter where they peaked my interest with:

… a game in which your narrative choices affect which missions you can play — and where your performance during these missions would affect subsequent narrative options. Divinity: Original Sin 2 Update #49 on Kickstarter



Divinity: Fallen Heroes – Announcement Trailer by Larian Studios, LLC

Now that sounds like a game I want to play. I will keep tabs on the new game.

And We’re Walking…

I started off my game with a basic level and movement. So two weeks ago in Can’t Take the Sky From Me I created a Goldilocks Sandbox. Not a complete first level but enough for me to move around in and test out ideas. Last week I decided I wanted to flesh out my movement. I chose grid-based movement like Bard’s Tale I had but I wanted some tweaks to it like in-level stairs creating multilevel environments in a single scene. I had already made numerous changes to the GridMove asset so a few more wouldn’t hurt. I implemented a run, walk, and crouch walk feature, and fixed a bug in my StartTile prefab. My player prefab wouldn’t start on the StartTile location in the Goldilocks Sandbox. I debugged it for a bit and realized Unity executed the player’s Awake() before the StartTile Awake(), which caused my bug, I had the objects communicating in Awake(). I rewrote the code to set the player location in the Start() method, and bam it worked.

TIP: Be mindful of Awake() timing in your objects. Make sure you put all object setup in the Awake() method, and save all inter-object calls and communications for the Start() method. See the Unity forum post here.

After I fixed that bug, I went back to the stairs issue. I still flew 230 meters into the air when I touched the stairs and didn’t know why. After I researched the issue a bit I realized that the player prefab had a RigidBody and all movement changes were done directly via Transform updates, which caused wonky physics at times (see the gif below). The RigidBody wanted to interact with the stairs and on the first step it did, that’s why the player flew up so high, after that the player walked through the stairs because the player’s Transform told it too. Now, like I said, I had changed the GridMove player prefab and code so much that I don’t know if I added the RigidBody or not. So I needed to go back to the original GridMove and find out. (Side note that here is where I discarded 17 years of version control experience and thought, “I got this.”)

I hope you don’t get motion sickness!

I copied my version of the GridMove.cs file to a separate folder and refreshed GridMove from the Asset Store. Sure enough the player prefab had the RigidBody from the beginning, kewl now back to my tests. I attached my copy of GridMove.cs to the player prefab and fired it up. Everything seemed right at first, and then I realized I couldn’t run or crouch walk anymore. Hmm, that’s strange. After checking the code I realized somehow I lost all the code I wrote during the week. Ah, Dropbox has a limited version history, I can use it to recover my work. Nope. Well shit, I really messed that up. Oh well, I’ve rewritten code many times before and I’m sure I’ll do it again in the future, but first I’m creating repo.

Version Control, D’oh!!

This brings me back to “I’m an idiot!” For about two weeks I told myself I needed to add this to git, but meh I haven’t made any important changes yet, I’m just playing around right now. Oh well, I suppose I have to burn myself every now and then to remember that fire hurts.

I’ve used Subversion for 17 years and I started learning git over the past few months. On Saturday I learned some new things about git, like large file support (LFS) (my assets folder is over 7.5GB) and when to use a gitattributes file. It took three distinct tries to get my Unity project committed to GitHub (I used a private repo). Over the course of the day I found GitHub for Unity and added it to my project, I prefer staying in my dev environment if I can manage it. I added the Unity .gitignore file to my project root folder.

TIP: In Windows File Explorer you can’t create a file that it only considers an extension, so trying to create “.gitignore” will give you an error. However, if you add a period to the end, “.gitignore.” file explorer sees that last period as the start of the extension and can’t identify the extension so it drops it and creates “.gitignore” instead. I tested this in Win7 and Win10.

As I learned about LFS I realized I would need a .gitattributes file. I read the documentation on it and didn’t get it on the first pass (ok or the second or third pass, whatever 😉 ). I ended up Googling it and found that thoughtbot had some great articles on How to Git with Unity, and Automatically Collapse Generated Files in GitHub Diffs. They had already done the hard work for me. I firmly believe that as a coder I need to spend more time coding meaningful work, and not rehashing already solved infrastructure problems. I have made exceptions to this rule, mainly when I needed to learn frameworks, APIs, or other large code bases, i.e.; Unity.

I read somewhere that GitHub for Unity would enable LFS when it inits my repo; well in my case it didn’t, so I had to mainly do it. GitHub for Unity also overwrote my .gitignore file, so I had to update that again. Then I realized that some files were committed that shouldn’t have been so I had to re-apply my .gitignore settings.

TIP: Always setup your .gitignore file BEFORE you init your repo, otherwise you create more work for yourself and your repo gets messy.

Then I made some commits to GitHub until I got to the monsters which take over 7GB. It took GitHub for Unity over 36 minutes to make push this to GitHub and I had no feedback in Unity on where it was in the process. Hmm, I didn’t like that, so it looked like I still needed to use git bash or GitHub Desktop in the future. I guess as a third option I could dig into the repo and propose updates. So much coding to do and so little time.

Keep On Questing!

I’m working the board game area at Ravencon this weekend, so I can’t quest as much as I want to this week, but I swear I’ll get moving again. 🙂

PS – before I sign off I want to mention that khawk created a new GamDev Challenge, a Side Scrolling Arcade Shooter Challenge – Without Weapons! It started 30 March 2019 and runs until 2359 UTC, 1 June 2019. I might divert some of my time to creating a small game that meets the challenge requirements. I’ll decide that this week.

Grinch gif sourced from Tenor.