Godot

7574 readers
4 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS
26
 
 

Hi everyone! Let’s program a simple effect that simulates looking at a scene through ribbed glass, also known as fluted glass. It’s a straightforward algorithm based on a combination of a few basic principles.

27
28
29
 
 

Hello, everyone! Let’s program this interesting effect, which allows us to successfully simulate the view through a glass window during heavy rain. The shader we create this way will have many parameters and customization options, so it can be used in a wide range of situations.

30
 
 

Pretty happy with what we were able to make! The game has a "flatscreen" mode too so you don't need a VR headset to play it.

https://copper-tunic.itch.io/chrono-crank

31
 
 

godot-rust goes into the next round with v0.5, just released on crates.io!

On the toolchain side:

  • We now support Rust edition 2024 and Godot 4.6 out of the box, as well as all versions >= 4.2.

  • WebAssembly support no longer needs LLVM/bindgen and is being unit-tested on CI.

  • It's now possible to depend on other godot-rust crates through rlib.

Some features added in this cycle:

Typed dictionary. Also, enums in Godot collections!

let tiles: Dictionary<Vector2i, Tile> = dict! {
   Vector2i::new(1, 2) => Tile::GRASS,
   Vector2i::new(1, 3) => Tile::WATER,
};

Non-null engine APIs:

// Instead of...
let t: Gd<Tween> = node.create_tween().unwrap();
// ...now:
let t: Gd<Tween> = node.create_tween();

Direct == &str comparison, saving allocation:

let s = StringName::from("hello");
if s == "hello" { ... }

Bitfield Debug impl:

assert_eq!(
    format!("{flags:?}"),
    "PropertyUsageFlags { EDITOR | READ_ONLY }"
);

Optional parameters -- call from GDScript as method(1) or method(1, 2):

#[func]
fn method(
    required: i32,
    #[opt(default = 100)] optional: i32,
) { ... }

Export tool button -- click in Godot's inspector to immediately execute Rust code:

#[export_tool_button(fn = Self::on_clicked, icon = "2DNodes")]
click_me: PhantomVar<Callable>, // not a physical property

We now also have a Games page showcasing projects that users made with godot-rust! And I'm still behind on adding new entries there :)

Huge thanks to the community for making this possible! Countless bug reports, PRs, and feedback based on real-world projects have helped godot-rust immensely to reach this point.

If you like the project, consider giving us a star on GitHub. As it's maintained entirely in free time without any financial backing, small GitHub Sponsor contributions are also very appreciated (Yarwin or TitanNano or Bromeon). Thanks to everyone supporting the project -- We are excited to see what will be built on v0.5!

32
33
34
 
 

I'm building a 2d platformer in Godot, and it's my first time with the engine.

I've followed the First 2D Game tutorial as well as a few others (Brackey's videos and some others) and have a decent grasp on building out a level as well as decent physics for how I want my player character to control.

So far, everything was made underneath one main Scene called "Game" and I'm at the step where I want to start having a Main Menu, a Level Select Menu, and logic on starting/completing a level rather than just one big "Game" Scene with a bunch of stuff I slapped together to test out the platforming.

I'd love some input on how I should be structuring my project and changing scenes around. I've found examples in tutorials but they all differ on some details and I'm not sure what is best. I've built a simple Main Menu and Level Select Menu and am able to go in and start the "Game" scene from it.

This is a big ask, I admit :).


  1. I've created a new main Scene titled "Main". It's jsut a plain Node with this script so far:
class_name Main extends Node


var main_menu_scene: PackedScene = preload("res://scenes/main_menu.tscn")

func _ready() -> void:
	add_child(main_menu_scene.instantiate())

func exit() -> void:
	get_tree().quit()

I've done this partly to follow an example that I found, but also due to how I want the background to work. In some Valve games, the Main Menu background is based upon the level you're at in the campaign. I want that. If you start the game up the first time, I want the background to be the 1st level background. If you're on world 10, I want it to remember and show that background. When the level launches, the background can stay the same as it was on the Main Menu.

I don't have backgrounds started in at all, yet.

  1. My Main Menu scene is a PanelContainer. Above, Main loads the MainMenu scene and adds it as a child. This works but I don't know if it's the best way. Script:
class_name MainMenu extends PanelContainer

@onready var main_scene: Main = get_parent()
var level_select_menu_scene: PackedScene = load("res://scenes/level_select_menu.tscn")
var options_menu_scene: PackedScene = load("res://scenes/options_menu.tscn")

func _on_play_button_pressed() -> void:
	main_scene.remove_child(self)
	main_scene.add_child(level_select_menu_scene.instantiate())

func _on_options_button_pressed() -> void:
	main_scene.remove_child(self)
	main_scene.add_child(options_menu_scene.instantiate())

func _on_exit_button_pressed() -> void:
	main_scene.exit()

This lets you exit (works by calling the Main scene function) go to Options, and go to the Level Select scene as well.

  1. Next is the Level Select Menu. It's similar to the MainMenu. Script:
class_name LevelSelectMenu extends PanelContainer


@onready var main_scene: Main = get_parent()
var main_menu_scene: PackedScene = load("res://scenes/main_menu.tscn")

func _on_back_button_pressed() -> void:
	main_scene.remove_child(self)
	main_scene.add_child(main_menu_scene.instantiate())

func _on_level_1_button_pressed() -> void:
	main_scene.remove_child(self)
	main_scene.add_child(load("res://scenes/game.tscn").instantiate())

func _on_level_2_button_pressed() -> void:
	# main_scene.remove_child(self)
	pass

Here you can go back (works) to the MainMenu, or move forward and start the "Game" scene I mentioned above. I intend to build a few levels and stick them in here in a similar fashion, replacing game.tscn. That will get me to the pre-pre-pre-alpha stage of my game and I hope to get feedback on how the platforming "feels" from there.

My thought is that the Main scene would handle the backgrounds, and always be the main parent Node in the Scene Tree. The Menus and Levels get swapped out as the child node of Main.


Questions:

Does this look ok to any of you Godot veterans?

Any code smells?

All of my scenes are in a /scenes directory. All of my scripts are in a /scripts directory. No sub-directories in either. This is quickly getting messy and I'd also love tips on folder structure.

35
 
 

Hi, everyone! It’s time to create something small in 2D again, and since simulating old devices can be very useful in games, we’ll take a look at a shader that mimics the behavior of a low-quality analog screen.

36
 
 

After a lot of tech torture, I finally got selectable provinces working in my map game! The way it works is the script checks the position of a mouse click on the collision mesh of the map against an image of the province map (which is dynamic and can be updated at runtime), which will select the corresponding province associated with that colour. This information is also passed to a shader which highlights the province on the map.

I spent way too long messing around with raycasting before I realised that Godot's _on_input_event signal does all the heavy lifting for you...

37
38
39
40
 
 

Hello, everyone! In this video, I will demonstrate how we can cut any 3D object into irregular fragments and then use them to simulate an explosion, for example, in a space shooter. We will start in Blender and complete the whole effect in Godot.

41
 
 

Hi, i'm still new to godot and learning but i'm curious what you would recommend for terrain generation an editing. I'm not really convinced of the unfinished plugins i found.

42
 
 

The map is procedurally generated and is filled with settlements populated by groups with procedurally generated languages, cultures and religions. This is still early days but I'm pretty happy with how things are going. The language generation still needs a bit of work (as does everything!), hence the weird city names

43
 
 

Might as well stick with 4.5 at this point and focus on actually completing the damn thing

44
45
 
 

Hello, everyone! In the previous tutorial, we programmed a 3D spatial shader, and this time we will stick to the same concept. In this video, I’ll demonstrate how to create a simple outline or glow effect for any 3D object in Godot 4.

46
47
48
49
50
 
 

Hello, everyone! Last time, we created a fairly interesting fire effect that works well in 2D games. This time, we’ll try transforming it into a 3D shader, put it on the surface of a cylinder, and observe the results.

view more: ‹ prev next ›