My main game project was a 2D top down platformer/adventure game with a 8 directional sprite-based character. This style of game required tons of different sprite sheets for all different directions the sprite was facing. There was also another problem. I wanted jumping in my game, and managed to implement it “sort of”. I was just offsetting all nodes in Player scene in the Y direction, except from collision and shadow sprite nodes. This worked in a way, but I also want to add several floors to my levels, this is when everything started to get too complicated for 2D. I think I would have gone with 2D if the game was a side-scroller, as that would have been alot easier to manage. The 2D game looks like this:
I then realized since i do not know how to draw pixel art, or anything else for that matter. So I figured i might start the blender course later and make some basic 3D models instead. I also figured the features i want should be easier to make in 3D than to emulate in 2D, so i started to make a 3D game instead ( I had no previous experience with making 3D games). The 2D game already felt fun to play even without enemies, I am pretty happy with the movement code i made in that project. So I tried to implement the same movement into my 3D game. The hardest part was to move based on the current camera direction, but i managed to implement some decent movement. My 3D placeholder assets are made by Kenney. This is what my 3D game looks like:
The movement felt pretty good on flat planes. You can download and try the game for windows, if you have a gamepad: https://fossegutten.itch.io/karatechop
In the 2D game i just jused the standard move_and_slide function of KinematicBody2D, but i quicly encountered problems with using the same approach in 3D. The main problem: Slopes. The player starts falling when you run down a slope too fast, because the gravity is applied too slowly and Player thinks he fell off a ledge. This results in player just bumps along the floor, instead of staying on the floor like we want. You can do a quick google search on “platformer slopes” to watch a video if you are not familiar with this, or try to run down a slope in my game. I quickly realized I do not have the skills to finish this project yet. So I figured I need a way to learn more about 3D game programming in general, but also the Godot specific 3D nodes. So I put this project on hold for a while.
This is when I figured I want to convert the Unity RPG course into Godot, to learn more about how to make a full 3D game. I also always wanted to finish that course, even if I do not like the Unity editor and prefab system at all. I finished section one in the course yesterday. The biggest challenges I had so far with the project:
Raycasting from mouse position to point in 3D world.
Layers in Unity and Godot engine are not handled in the same way.
Ben and Rick using the “Ethan” character from asset store in unity. I needed to program my own character from scratch.
Ben using delegates in C#. I am using signals instead and connecting nodes through code, not in the editor.
I learned some valuable stuff:
The raycasting was a bit harder in Godot compared to unity. But i figured it out in the end, and learned about tons of new stuff in Godot engine as a side effect. I had to access “direct_physics_space” and cast rays from there, into the 3D world. There is also a way to specify physics layers you want the ray to hit in there, you just have to look for it This is essential knowledge for making desktop and even mobile 3D games, and was worth all the hours I spent on this!
So i figured out how to handle the slope movement, by detecting the angle of the floor below me with a RayCast node, now i can ascend and descend slopes smoothly! This is the thing im most happy about in my game development journey so far, because i realized that I can make a great character controller now! Obviously it needs a lot more work to feel as good as a Super Mario game. But hey, Rome was not built in a day Here is a hint if you want to do something similar: Learn about cross product for vectors.
I also learned how to smoothy rotate a character in 3D. This is essential for the game to work with both direct (gamepad) and indirect (mouse) movement. The rotation stuff was quite hard in my opinion, as it is not as simple as linear interpolating the angle. Example: The positive and negative values the value can just snap f rom 270 to 0 degrees, instead of continuing from 270 to -90 degrees, like you want it to. Time to do some complicated math again!
The game looks like this after Section 1 in Unity RPG course:
Example of my slope movement , without applying gravity:
And an incidental “feature” I made, when working on the raycasting! Maybe i can use this for a game later?