Category: godot

Update

It has certainly been a while. I’ve been recently busy with a new job I started earlier this year. Nevertheless, progress has continued on my game, but there has been a lot of changes in the direction which I wasn’t sure how to address so I kept putting off making a new post.

I’m currently working on a dungeon crawler-esque type of game. But I’ve switched to 2D, specifically a top-down game. The biggest reason for this change was issues with getting good animations for 3D models that I made. So I’ve put the 3D game on pause for now, and have been working on this new game in 2D, which I’m still working on in Godot, version 4.2 specifically at the moment.

Below is a quick photo, I’m using a free pixel art asset pack called Pixel Crawler I found on itch.io. I’m not sure if it is temporary or will be what I use in the end, but it looks okay for now.

Essentially you control a mage that crafts spells from ‘spell fragments’, which are these granular components of spells. So you could create a spell that explodes and hurts enemies, or one that pushes enemies away. The system for creating spells is quite complex and I’ll be showcasing some of it in future posts.

I’m thinking it will be called Nebulis but I haven’t settled a name just yet.

More to follow!

Tweening

I just wanted to take a moment to write about one of my new favourite features of Godot 4.

Tweening! Now this existed in older versions of Godot, but you had to instance a ‘tween’ node in your scene and then reference it through code to get your tween to work.

For those un-aware, a tween in a video development context is to essentially smoothly move a property from one value to another. For example, say you want to make some text fade in, you could tween the alpha channel of that text from 0 to 1 over the course of say a second.

In Godot 4, they made this much easier to do by creating a new helper function called ‘CreateTween’ off of the Scene tree, so you can do things such as…

Tween tween = GetTree().CreateTween();
tween.TweenProperty(this, "modulate", new Color(1, 1, 1, 1), 0.1f);

This would (assuming that the alpha was set to 0 at the beginning) fade in the object over the course of 0.1 seconds. You can chain properties too, like this:

tween.TweenProperty(this, "scale", new Vector3(2, 2, 2), 1f);

If you add that line after the previous two, after 0.1 seconds of fading it, it would double in size over the course of 1s by tweening the scale property to (2, 2, 2). You can also tween other things such as methods (for example, you could Tween a call to QueueFree() to delete a node after X amount of time!)

There are many examples available on the Godot documentation regarding tweening. There are many ways to customize and tweak how the values transition between values. The change in Godot 4.0 to allow you to quickly and easily create a tween programmatically really reduces to barriers to adding tweens to your game on the fly.

I’ve been using it a lot, especially to give more character to the user interface by making things slightly larger or fading in / out.

Will provide updates about projects I’m currently working on soonTM

Trivo.. 2?

It has been quite some time since my last post. Since then lots of work has happened on Trivo in Unity. I had ported most of the old systems outside of all the old user interface code since that was mostly specific to Godot.

The last thing I worked on was, after getting the A.I behaviour trees working in Unity properly, was messing with Unity’s inverse kinematics with the purpose of moving the character’s palm towards a location to make it look as if they were casting a spell without a dedicated animation for it.

Here is a video below of me experimenting with that:

I was quite happy with the result. I also managed to get tower floors generated out of random rooms with all their doors aligned properly.

But as I continued working in Unity on this project, I felt like I was still so far from my goal and decided to take a step back and go back to Godot 3.5 and create a simpler 2D game. The idea being that I could finish a 2D game in Godot in a short amount of time before going back and continuing work on my 3D game in Unity.

I’ll be posting more about that in the future, but here’s a little spoiler: It’s a top down game where you control a ship!

Until next time!

Trivo…

I haven’t posted recently, and there is a good reason for doing so.

I ran into issues with the Godot engine, I believe I was running into some very odd stack corruption issues where the game would crash with no crash / debug information at all. I tried for about a week to debug it and eventually found that upgrading to Godot 4.0 fixed it. Unfourtunately Godot 4.0 is quite buggy which was really slowing down my progress. I decided to start porting things over to Unity mostly because I was worried of another such bug occurring in Godot 4.0.

So currently, I’m porting things over to the Unity game engine. Which I’m kind of upset to do, since I really do enjoy Godot’s node tree and work flow much more than the Unity equivalents. We’ll see how the next week or so goes as I continue to port over my code, thankfully they both offer C# as a scripting language most of my issues will changing specific Godot specific solutions to Unity.

One example is Unity has no concept of separate worlds which Godot did, so I have to re-work my zone management code to instead instantiate zones in floating sections of space to separate them instead of just being able to create an empty new world for each zone in Godot.

Anyway, I hope to give a update soon about the progress of the port.

Entering the Tower…

I’ve been working on the mechanic for entering the tower so you can start a run in Trivo.

Since the game is being designed with multiplayer in mind, I’ve decided to create a system that allows players to start runs, or to join other on-going runs.

When you go up to the tower to begin, you’ll be prompted by a pop-up window whether you want to start a new run, along with the option of joining any on-going as you can see from the pictures below.

enter tower ui
No active runs
enter tower ui
One active run… by ‘PlayerEntity’

Currently it looks very plain / ugly at the moment. I just got the starting of new runs and the joining of on-going runs done with this very basic looking window. I plan to re-vamp the look now that the functionality is complete and will probably post a picture of the new one in the future.

Tower Floors

My recent game development time has been going towards working on randomized floors that the tower in Trivo is made up of. The idea is, similar to other dungeon crawler like games, that the layout is completely randomized.

The idea for Trivo is that, as you ascend the tower, you go floor by floor. Each floor is composed of randomly arranged rooms. I plan to creates hundreds of these rooms to randomly pick between, along with also randomizing things inside the room such as the types of enemies.

randomized floor layout
A random 35 room floor plan

Above is a “floor plan”, essentially I generate this structure above and note all the dead ends and the starting square.

I use the dead ends to put any special rooms (such as the final room of a floor) that leads to the next floor. So essentially I generate a floor plan like above, pick a random dead end that isn’t too close to the start and mark it as the exit of the floor. I can then use other random dead ends for other special rooms such as a room that may contain no enemies but may contain some treasure for the player.

This is a little sneak peek into the floor generation, and I plan to post more about the actual rooms themselves in the future.

Campfire fire

One of my earlier posts included a campfire, among other light source models.

After importing them into Godot I took advantage of the built in 3D particle emitter and some lighting nodes.

campfire godot scene tree
The campfire Godot node scene, composed of the mesh, particle emitter, and a light source

With a little bit of effort and some messing about with the particle emitter, I got some very basic looking fire that will work well for my use case. Below are a small video of the campfire and a torch.

Godot

Last year I messed around with a game engine called Godot, and enjoyed how simple and lightweight it felt. I’ve used Unity in the past but after trying out Godot I preferred it instead. The way it handles game scenes is great, and I found I could get a lot more done in short amount of time in Godot compared to Unity.

The game is currently being worked on in C#. Initially it was 100% written with GDScript, a scripting language similar to python specific to Godot, but I personally prefer a statically typed language. I got frustrated with GDScript as the project and my scripts got larger and eventually decided to re-write the whole thing strictly in C# which is an option for scripts in Godot. So far, so good.

add new script to node
Attaching a new C# script to a node in Godot

Another goal of the re-write was to leverage a new networking solution (SteamNetworkingSockets) instead of the built in networking provided by Godot which uses ENet. I plan to write more about my networking in the future.

When working in Godot, every game scene is a collection of nodes, which can have nodes as their children. Essentially every scene is just a big tree of nodes.

bundled nodes
The ‘Create New Node’ window in Godot

You can instantiate these scenes easily during run time. For example, I have a player scene, and a game scene. When a player joins, I create a new instance of my player scene and add it to the game scene. Every important part of the game is a scene, which are all just composed of nodes.

In contrast to Unity which has objects which you modify and save as ‘prefabs’ to instantiate later and a entity component system (at least the last time I used it that’s how it worked), Godot felt more intuitive and straight forward. Everything was a node.

For a quick example, in Unity you might have a generic object, and to make it render, you attach a sprite renderer component, in Godot you’d add a Sprite node to your node.

node with a sprite node child
A 2D node with a Sprite node child

Anyway, I’m kind of rambling but basically I enjoyed how Godot worked and for my use case it performs perfectly, and Trivo runs quite smoothly on it so far. I plan to keep using it unless it somehow fails to provide what I need for Trivo. With Godot 4.0 coming soon I’m excited to see all the new changes.

Godot NodePaths

So recently I’ve been doing the user interface for Trivo, and I had been referencing all the control nodes that I needed by creating string variables and storing the path to them.

This worked, but anytime the scene’s node hierarchy changed, my hard-coded string paths would all be incorrect and have to be updated. This caused changes to the UI to be quite cumbersome since I had to copy new node paths over to my code each time.

I got fed up with the workflow and looked for another way, and I can’t believe it took me this long to figure a cleaner way to manage references to the nodes I want to manipulate in my scripts.

Essentially, Godot has a nice feature that allows you, in the editor, to set a scene’s variable. Godot also features a handy variable type called a NodePath which is just essentially reference to a node in a scene. Combining these two features allows one to easily add NodePaths to your script which you can then set to nodes in your scene that will automatically update even if they’ve been moved.

A picture of the script variables, which you can set to nodes in the scene
The node path selection pop-up in Godot

This is pretty simple, but for whatever reason I never leveraged it until now. Glad I’m using it now though, makes changes to the scene tree much easier when I don’t break all the references in the script.