r/godot • • 20h ago

free tutorial The Programming Pattern that built Slay the Spire 2

Thumbnail
youtu.be
337 Upvotes

There's already a lot of deep-dives into Slay the Spire 2's codebase (which you should totally check out if you own the game), but I wanted to talk about the core pattern it uses to make all of it's cards, relics, potion, powers, etc work.

It's all hooks.

(and maybe the Template pattern if we really need a OOP name)

There's a lot of cool stuff talked about in the video, but I wanted to discuss more in depth how the overall pattern works here, along with some pros and cons. The main use case is a game where you want a variety of different "items" that can cleanly trigger different affects on the game state, making it easy to add new items and new effects. Here's how it works:

  1. A base class defines all of the event hooks.

These are game events that are broken up into specific, empty hook functions. For example, `beforeCombatStart()` or `afterItemAddedToInventory()`. The important thing is that one base class holds all of these hooks, and they all have a default implementation that does nothing. This means child classes that inherit from here can stay empty, and only define the functions they want to override

A game manager will then loop over every item that's active, and call it's hook function. For most items, this will be empty from the default implementation.

Additionally, there can be multiple hook functions for a single event to ensure the correct "order of operations". The best example is calculating damage, because if everything was calculated under a single hook, effects for additive and multiplicative changes would mix and make an inteterministic result. STS2 gets around this by breaking the hook into:

- `modifyDamageAdditive()`

- `modifyDamageMultiplicative()`

- `modifyDamageCap()` - ex, if enemy can only take a max of 9 damage per hit

These all get calculated in that order.

2. Core functionality comes from static "command" objects

This one is a little interesting, because you constantly hear about "not using globally accessible classes/vars", but here it simplifies the design substantially. Instead of saying "this is bad practice", here's the pros and cons that I could think of:

Pros

- Easy access to call commands inside other classes

- Simple

- Logical grouping of functions in classes (almost like a util library)

Cons

- If a functions contract changes (ex need a new parameter, return type, etc), it would require changing every invocation of that function

- Harder to isolate unit tests (you can't mock a "PlayerCmd" object as it's directly called by the class, so if you had a test suite and something was wrong with PlayerCmd, it could appear as failures in unrelated classes)

The big one that I think most people have run into is changing the contract, but it seems like they have a pretty stable design so they can afford to take that risk. In other words, if you really know that something isn't going to change, you can afford to keep it simple.

Thanks for reading! (and/or watching)


r/godot • • 13h ago

projects Super Rope: realistic ropes and chains for Godot (textured ropes, cranes, wrap around, leashes, etc)

313 Upvotes

Super Rope was released a month ago, and today I released v1.2.0 which makes it even cooler!

It supports textured ropes, wrap around objects, tug of war, leashes, chains, etc. It has multiple samples which you can play around in the browser https://alfredbaudisch.itch.io/super-rope-godot

In the crane sample you can reel in and out, and also attach rigid bodies.


r/godot • • 16h ago

projects Procedural weather in my Godot 4 survival game: rain rolls in, and every biome reacts differently

160 Upvotes

Hey Godot folks! I wanted to show off the weather system I've been building for my survival game.

Weather fronts drift across the world with the wind, and the biome underneath decides what happens. A swamp gets soaked, a meadow gets rain now and then, and the desert mostly just watches clouds go by. The rain doesn't just switch on, either: the sky slowly gets darker, the wind picks up, and then it starts pouring.

Godot made a lot of this really fun to put together. The sky is a custom sky shader, the clouds near the camera use a FogVolume so you can actually fly into them, the rain is GPUParticles3D, and global shader parameters let grass, trees and water all react to the same wind and rain. All the logic is plain GDScript.

Still polishing it, but I'm really happy with how alive the world feels now. Happy to answer questions!


r/godot • • 10h ago

projects My WIP action game inspired by Chinese martial art.

136 Upvotes

r/godot • • 11h ago

free tutorial I added geometry-wrapping rope the player can rappel from and here is how I did it:

91 Upvotes

This was a tricky one! Gonna explain how its done in case anyone else wants to implement something similar. Godot's static physics state queries make it surprisingly easy.

tl;dr After a bit of testing I decided against a fully physics-based rope that relied on RigidBody3D motion. Instead I fake the last segment of a geometry-wrapped Curve3D as a tension-pulling pivot or pendulum depending on player state.

I start with a RayCast3D from the player camera to get anything in the group anchorable including physics objects. This is the main reason the rope isn't physics based - I wanted the anchor and move-able objects the rope wraps against to remain solid and prevent unexpected jumps in rope length at tension thresholds. Instead of freezing everything I'm using a Curve3D and physics shape casting.

Every frame my code counts the rope segments and creates or moves a capsule collider to line up with it. It simultaneously syncs a MeshInstance3D to render the capsule. In the default physics engine they are on a single collision_mask layer to let the player grab on to and let go of the rope. The shapes are then reused for shape cast queries.

The curve starts with 2 points: the anchor and the player. Every frame I use the adjacency collision shape that's synced to the last rope segment for a PhysicsDirectSpaceState3D.get_rest_info(query) query. If it returns a collision with geometry I insert a new path control point offset from said point by the rope radius in the direction of the collision normal.

As the player moves around level geometry the rope they are attached to cleanly splits so they always have direct line of sight to the pivot. This is important because I'm faking tension by capping player velocity on the axis of the last curve segment.

Critically, I only let the player extend or contract the rope with direct input velocity. Any other forces on the player are fully clamped along the rope's axis.

Every frame we also need to check the unwrapping condition by shapecasting between the player's harness and the point at pivotIndex-1. If its empty, remove the active pivot from the curve and swap the pivot index. I also check for unwrapping along the length of the rope with the casts debounced to 3 per frame.

The last thing that makes this work is adding a centering force when the player is hanging below the pivot. This acts like a pendulum by taking the sin of the angle of the gravity vector and applying it tangent to the pendulum arm. Wikipedia has some good diagrams on the topic.

I hope this helps someone in the future trying to implement a similar mechanic. I spent way longer than I care to admit trying to figure out how to do this.

The repositionable ladder is a another story for a different day haha. Let me know if you're interested in a breakdown of that too!

Video alt text: Screencast of a WIP backrooms-themed video game. The player begins in a yellow-lit room with chevron vinyl wallpaper, drop ceilings, fluorescent ceiling lights and faded beige carpet. The first frame of the video is filled with furniture, but the player quickly singles in on a couch and moves it back against a wall. The player attaches a rope to the couch and uses the rope to rappel down a hole in the floor where they find a ladder. The player detaches from the rope and picks up the ladder. There's an obvious raised section of floor where the ladder is supposed to go so the player maneuvers the ladder into place. The player climbs up the ladder and up into a narrow, square crawlspace they couldn't reach before. After crawling for a moment, they are able to stand and climb up through the floor into a new room filled with duplicated wooden rocking chairs and a small floor depression.


r/godot • • 4h ago

free tutorial Beginner Godot forest environment

Post image
67 Upvotes

Hello there 👋,

I have just uploaded a beginner friendly complete tutorial + series on godot.

If you enjoy the crash course, make sure to like, comment and subscribe for more.

Video link : https://youtu.be/K-gtB6_qQBU

GitHub link : https://github.com/Lakshman-YT/Forest-Godot4

Itch ( paid horse project + forest) : https://gw-tuts.itch.io/horse-controller

Disclaimer : this video does not showcase godot full potential on forest creation, this project is purely my experience on creating some good looking environment on godot.

The purpose of this video is for beginners learners to learn some level design in godot.

I don't claim it as photorealistic or ultra realistic forest in godot. So please avoid repeated questions / comments on this topic.

THIS IS JUST A PERSONAL PROJECT.


r/godot • • 17h ago

projects Timelapse of a custom 3D progress bar – from Blender to Substance Painter to Godot

56 Upvotes

r/godot • • 13h ago

help I don't know if I should go with pixel art text or normal text

Thumbnail
gallery
55 Upvotes

Hi! I've been doing this video that is supposed to be on an old computer. Thing is that a lot of this game has a lot of text and requires reading, but I realized that the pixel fonts can be somewhat unreadable (or too big on fullscreen, in between sizes make the pixels have inconsitent sizes).

I tried some fonts from Google Fonts (idk also if these are to overused) and I've even made my own pixel font, but idk, still I am very unconvinced.

The not pixel art font is supposed to look retro but it is not pixel art, but as you can see from the main menu, the not pixel art font clashes with the pixel drawing I have.

Also, in different resolutions some pixels look bigger than others because of some weird interger division that I cant seem to get right (look at the "trees" on the last picture, which I am also thinking about redrawing because of this issue).

Idk if this is a real issue or something that only I care about as the developer that has just been staring at this for too long. Any feedback helps, thanks!!!


r/godot • • 19h ago

projects Really happy with how my skeleton boss turned out!

40 Upvotes

Hi all,

You all seemed to really like my game last time and the project has come on further since then so thought I'd show off one of the bosses in my game!

I made the pitch a single mesh so the shaking tiles are actually just copies stacked on top of the real ones. They bounce under the hand and disappear when they land. Not sure it's the most optimal way of doing it but I think the effect looks really good!

You can wishlist here: Football Tactics: Dare to Dream


r/godot • • 19h ago

projects arcade-y mecha game, awesome?

37 Upvotes

I made this over the course of a few weeks back in September and got too busy with university so I had to take a break from game dev. I've got the itch to make games again, y'all reckon I should keep working on this or should I start a new project? I've got a couple ideas floating around, but maybe it's time i commit to a game...

(models and music made by me, textures and audio taken from opengameart.org)


r/godot • • 20h ago

projects 3D background for a 2D game - testing look and feasability

27 Upvotes

Hey folks, wanted to showcase something that I have been working for the past couple of days and that is can I render a 3D background in a 2D game.

This is just a test scene to test the work involved and to see what it would take to do it.

The position of the hud and other things needs work but the aim of this post is just to showcase the result.

I am using a free pillar model from Sketchfab for testing that you can find here: https://sketchfab.com/3d-models/stone-rock-column-pillar-c7bc16708bf94eb98d56fe90ae9ac0e7

Also running a simple shader to try and make it look more like pixel art but it is still very rough and probably needs some work.

Curious to know if anyone has tried this before and what you think overall.

Thanks!


r/godot • • 23h ago

projects month 3 of making my dream mx game!

16 Upvotes

Full video here

This is my dirtbike game MX legacy 3 months into solo development (:

Just wanted to come here and show my progress.


r/godot • • 19h ago

help Fast Array Library?

15 Upvotes

Does anyone know of an extension that provides Numpy-esque arrays? with slicing and fast math operations. I feel like this is a commonly desired feature so I would be surprised if it didn't exist. If not, I may look into making one myself.


r/godot • • 4h ago

projects My WIP bullet hell game

14 Upvotes

If anything feels off about it, or if you have a suggestion or anything, please pray tell!


r/godot • • 7h ago

projects I released my first Godot game

14 Upvotes

I've tried to make games for many years now but I just never really pushed myself to keep going.

That is until I learned about Godot roughly a year and a half ago and then decided to try to learn the engine. Very thankful that I stuck with learning the ins and outs of the engine as I now have a finished game on Steam. It's nothing crazy, but is still a game that I would play so I made it myself. You can check it out here if you are curious.

I have come to really like using Godot and am already looking to work on a new project and to keep learning new things with the engine. I haven't gotten into the 3D side of the engine just yet so I think I might start there.

Good luck to all who are learning Godot!


r/godot • • 12h ago

discussion How do you approach adding translations/alternative languages to your game?

13 Upvotes

As the topic says - is this something you bake in at design time, or do you not bother? Do you get a translator, or just use an online service? Do you wait to see if there is a requirement? What languages would you say are the defacto languages?

English
Spanish
French
Russian
(sorry if I missed your mother tongue out here!)

Eventually my game will be very verbose (in a textual way) - and would like to ensure it is accessible by as many players as possible.

So, how do you approach this - any real world examples?

Thanks!


r/godot • • 21h ago

free plugin/tool Free top-down pixel art for Godot: everything in this dungeon room is free (characters, boss, items)

Thumbnail
gallery
12 Upvotes

Everything in this GIF is free: the dungeon tiles, torch, chest, coin and potion, the Knight and Rogue, Slime, Skeleton, Goblin, Gnome, the King Slime boss, and an animated spellbook + scroll.

For Godot: each character is a PNG sprite sheet with one row per animation (idle, walk, attacks, hurt, death × 4 directions) plus a JSON file with frame durations and tags, so it's quick to set up in AnimatedSprite2D. The tiles are a 32x32 grid with the wall tops laid out for autotiling.

- Top-Down Heroes LITE (Knight + Rogue): https://tinytileset.itch.io/top-down-heroes-free

- Top-Down Monsters LITE (Slime + Skeleton): https://tinytileset.itch.io/top-down-monsters-free

- Orc Warband LITE (Goblin Stabber): https://tinytileset.itch.io/top-down-orc-warband-free

- Elemental Spirits LITE (Gnome): https://tinytileset.itch.io/top-down-elemental-spirits-free

- Boss Pack LITE (King Slime): https://tinytileset.itch.io/top-down-boss-pack-free

- Grimoires & Scrolls LITE (spellbook + scroll): https://tinytileset.itch.io/grimoires-and-scrolls-free

- Dungeon Tileset LITE (tiles, torch, chest, coin, potion): https://tinytileset.itch.io/top-down-dungeon-tileset-free

🎮 Made a game with them? Share it in the comments here or on the itch page. I'd love to see it, and I'll feature the best ones!

⭐ If these helped you, show some love on this post and follow me on itch: https://tinytileset.itch.io 🙏

Ask me anything about setting them up!


r/godot • • 8h ago

help (solved) 3D newcomer, how would I make this work?

Post image
10 Upvotes

Hey! I've been coding games for quite a while, but I was focused in 2D and 3D still feels a bit painful... But after learning some Linear Algebra it has gotten a bit better.

So, I'm making a SICK SUPER COOL ASS player controller which can do one thing no other controllers can - DASH (I know very unique)

And I want to make so player will gain additional upward velocity based on how steep the ramp is. Right now it works, it checks for the normal (blue arrow) and applies the upward velocity after that (red arrows). But, I never check whether the player is facing the ramp or not, so even if they are getting of the ramp the upward velocity still applies. And I want for the player to just slip off of it.

And I'm not sure what's the best way to handle that? Thanks for your answers!

Solution

Thanks to everyone! I've gotten the solution from Discord, it was actually pretty easy. Al you gotta do is dot the forward vector of a player with the floor normal:

Vector3 floorNormal = _player.GetFloorNormal();
if (_player.IsOnFloor() && floorNormal.Y != 1)
{
    if (_player.Head.Transform.Basis.Z.Dot(floorNormal) > 0) 
    v += floorNormal * _player.DashSpeed * 0.5f;
}
_player.Velocity = v;

r/godot • • 23h ago

help Godot Documentation is confusing to me

10 Upvotes

so I'm new to godot and game dev in general, and I heard if you have a problem you should search the godot docs. but whenever I try searching for a node or a built-in function for example, it often gives me completely different results than what I was looking for. which ends up confusing me even more and nearly results in a panic attack or sensory overload because of how much information and stuff there is (which for most people is a good thing but for me is very overwhelming). but now sometimes if I were to just google for the thing I need to know, it will give me a direct link to what I was looking for in the godot docs. I've been trying to force myself from using youtube videos for help out of fear of constantly relying on them. but with how confusing the godot docs are to me, idk if I should just give up on learning game dev at this point with how stressed I am because I can't even read the godot docs and with how stupid I am. does anyone have any advice for using to godot documentation without getting overwhelmed and stressed.


r/godot • • 9h ago

help How can I use the same AnimationTree for multiple characters with different animations?

7 Upvotes

Hey! I'm making a 3D game in Godot and I'm using an AnimationTree for my characters, but I've run into a little problem...

I want to have multiple characters in my game, and some of them will share the same states. So ideally, I'd like to reuse the same AnimationTree for them.

However, in the animation fields, I can't seem to assign a different animation for each character. For example, let's say I have 3 characters, and each one has their own walk animation:

- "walk_char1"

- "walk_char2"

- "walk_char3"

How would I go about setting up a system that manages this better? Is there a way to keep the same AnimationTree/state machine while dynamically changing which animation each character uses?

Sorry for my english!


r/godot • • 20h ago

help Any way to give scripts their own tab?

7 Upvotes

I love Godot, but I find that one thing that makes it slightly harder to use is that only Nodes have their own tab. If I want to go back to a script, I have to find it in the list every time. Is there a way round this?


r/godot • • 19h ago

projects Screenshake + particles + squash & stretch + vertical fall = more fun

6 Upvotes

r/godot • • 1h ago

projects Hacking ability for my Katana Zero x Edgerunners inspired game!

5 Upvotes

I'm making a game that's inspired by Katana Zero gameplay in a cyberpunk Edgerunners like world. I tried making a hacking ability for Kaizen where you can press right click and he'll shoot out a raycast and play this glitchy electric animation where you can basically hack anything from enemies, doors, platforms, turrets, etc.


r/godot • • 17h ago

help Dragon quest battle system

4 Upvotes

GodotRulz Hi, I have a question. I’ve seen some tutorials on creating turn-based RPGs, but I’d like to make one in the style of Dragon Quest, where the player’s party chooses their actions, and then those actions are executed alongside the enemies' actions. The tutorials I’ve come across seem to handle turns individually for each character, does anyone know how to implement this, or can recommend a tutorial?