- Edited
Hello everyone,
I switched from Unity to Godot last week and thought it would be fun to document my learning journey on this forum. I hope that's okay with everyone!
I'm open to all kinds of feedback—be it critiques, tips, or general advice. Really looking forward to a fantastic learning experience and a great time with this awesome community!
Now that the intro is out of the way, let's dive in:
What's New:
- Getting Comfortable with Godot's Interface: It's pretty slick, I must say.
- Understanding Godot's C# .NET Syntax: Going pretty well since it's similar to Unity's.
* [Exposed]: Easy way to show variables in Editor (like Unities [SerializeField].
* Ready: It's like Unity's Awake and Start combined.
* Process(double delta): Equivalent to Unity's Update method. - Brushing Up on 3D Graphics: Revisited the basics of vertices and triangles in 3D meshes.
- Mesh Creation: Successfully created a simple mesh with shared vertices.
- Height Mapping: Implemented height to make the mesh more appealing. Looks significantly better with varying heights!
Challanges and Solutions:
- Understanding Square Generation: Initially, I made it so each square has four vertices and two triangles. Each triangle requires three vertices, leading to 6 indices per square. In a 10x10 grid, that would lead to 400 vertices (10x10*4) and 600 indices (10x10x6).
- The order of storing indices needs to be counter-clockwise to create a square as follows: bottomLeft->topRight->topLeft (Triangle 1), bottomLeft->bottomRight->topRight (Triangle 2).
- The order of storing indices needs to be counter-clockwise to create a square as follows: bottomLeft->topRight->topLeft (Triangle 1), bottomLeft->bottomRight->topRight (Triangle 2).
- Implementing Shared Vertices: I realized that many squares share at least two vertices, making it unnecessary to duplicate them. This mkes it so:
- The number of vertices for a 10x10 grid drops from 400 to (rows + 1) * (cols + 1), which is about 70% fewer vertices. The number of indices remains at 600.
- Instead of generating vertices per cell, I now generate only the bottom-left vertex for each square.
- To fetch the stored vertices needed for forming the triangles, I used the formula that can be seen from the image below:
where, in the code, it would look something like this:
Up Next: Diving into Shaders
The next big task is to get a grasp of shaders. Specifically, I aim to learn how to unwrap textures and apply them to the grid squares in my turn-based strategy game. This will involve:
- Understanding the basics of shader programming in Godot.
- Learning how to unwrap textures onto a 3D model.
If anyone has resources or tips on learning the basics of shaders in Godot, I'm all ears!
Questions/Feedback:
Few queries and challenges have popped up that I'd love some community insights on:
- Wireframe in Play Mode: Is there a way to toggle a "wireframe" view while the game is running? Currently, I'm using an additional MeshInstance3D layered on the original one, but is there a more efficient way?
- Editor-Only Scripts: In Unity, I could use "if UNITY_EDITOR ... endif" to include editor-only scripts. Is there a similar functionality in Godot?
- Limiting Exposed Variable Ranges: I'm trying to limit the range of values exposed in the Godot editor using "Range", but it's not behaving as expected. Has anyone else experienced this issue and found a workaround?
- Would you like for me to create a GidHub link if someone would like to download it at any point in time?