/r/godot
The official subreddit for the Godot Engine.
Meet your fellow game developers as well as engine contributors, stay up to date on Godot news, and share your projects and resources with each other.
Maintained by the Godot Foundation, the non-profit taking good care of the Godot project - consider donating to https://fund.godotengine.org/ to keep us going!
Looking for Godot?
Download the engine, Donate to the fund, Follow us on socials & more! Official Link-Collection
Subreddit rules:
1. English only, please
For moderation purposes, please stick to the official language of this subreddit, both for posts and comments.
You may link to sites in different languages, if you add a clear explanation what the content is about.
2. Code of Conduct
Read it here
Breaching the code is a ban-able offence. In particular, we won't tolerate discrimination or bullying of any kind.
3. Use appropriate flairs for your posts
If you don't, we maintain the right to delete the post in violation of this rule. Flair descriptions: https://www.reddit.com/r/godot/wiki/index/flairs/
4. Help rules
Repeated neglect can result in a ban.
1. Consult the documentation first
2. Search for your question before posting
3. Concrete questions/issues only! Don't ask "How to make X" before doing research
4. "Can Godot be used to make this game?" Yes.
5. Don't post photos of your screen, screenshots are okay, direct code with formatting or a pastebin is best
6. We recommend checking the official forum for solutions as well. Make sure to link between the platforms when you cross-post questions.
5. Promotion rules
You are required to use the promotion flair whenever you want to showcase your game. Do NOT use the "discussion" flair. You may use "fun & memes" when applicable, but do so sparingly and tailor your post to match the category.
6. Discussion rules
This flair is for constructive conversations, not for venting your frustrations. Should you have feedback for the engine development team directly, please open an issue or proposal on GitHub instead. Email the Code of Conduct team at conduct@godotengine.org for any "people problems" you might have. For reddit-specific problems, please use the ModMail or report functions. Do NOT use this flair to showcase your game, see the rule above.
7. Post memes with consideration
They must have the "fun & memes" flair, be related to Game Development, and the topic/content cannot breach the Code of Conduct. Do not spam memes.
8. Stay on topic
This is a subreddit about the Godot Engine. While related Game Development topics are not forbidden, please make sure to tailor them towards the Godot project. This means NO ART posts unless you are talking about the technical side of things - there are enough other outlets to post your pretty renders and concepts.
9. Getting started
Reference this https://docs.godotengine.org/en/stable/getting_started/introduction/index.html before asking for general advice/help. Posts asking "Where do I start?" will automatically be locked, due to this subreddit overflowing with them in the past
10. Copyright & AI-generated content
For legal reasons, you may only post content that you are the rights-holder of. This means you are required to credit assets according to the licenses you acquired them under. Some licenses permit sharing content without listing your sources, others do not. In particular, this means that AI-generated content needs to verifiable stem from a model which was trained only on data submitted with the original creator's consent. If you cannot prove this to be the case upon request, we remove your post.
/r/godot
So i set up a BlendSpace2D inside an Animation tree for basic 4 way movement.
the only issue im running into is that when the blend poin t is set to 0,0 it still continues playing the left facing walking animation. i have double checked that it is indeed set to 0,0 and it still plays the left walk animation.
i have also tried manually setting the sprite frame directly in code but the animation tree seems to override it. and i also tried setting the animation player to stop but the anim tree overrides that too. im not sure why, ive never hasd this issue before.
any help would be greatly appreciated and happy to share more if needed. thanks!
I'm trying to export my game for windows and some UI elements are didn't shown (first video), but in the engine, they work fine (second video). I alos tried exporting for web and it didn't work too. If you have any solutions, let me know.
Hey so I am making a td game but how can I make the script in the image reference a var under the gametemplate node?
The enemy is instanced by script(td game) and is put under path 2d.
I guess it’s farm now
I placed a sprite from a TileMap in my scene. Is it possible to move it to specific coordiantes/cells without code, directly in the editor?
Managed to get vertical text working, but still not fully working by using RichTextEffect.
A comparison of each vertical text with the default along with any problems
RichTextEffect script used for Mongolian Script text:
u/tool
extends RichTextEffect
class_name MongolText
var bbcode = "mongol_text"
func _process_custom_fx(char_fx: CharFXTransform) -> bool:
char_fx.transform=char_fx.transform.scaled_local(Vector2(1,-1))
return true
RichTextEffect script used for Japanese text:
@tool
extends RichTextEffect
class_name VerticalRL
var bbcode = "vertical_rl"
func _process_custom_fx(char_fx: CharFXTransform) -> bool:
char_fx.transform=char_fx.transform.rotated_local(-PI/2)
#to offset the font size
#char_fx.offset.y+= 100
return true
Most of these issues, stem from the font spacing not being factored when just rotating or scaling characters.
Any ideas for better implementation, I'm going to open an issue on Godot's source code as well.
https://reddit.com/link/1hirwda/video/oqnhwrt1428e1/player
The gun only shoots straight if it is completly horizontal how to fix this?
In Half Live 2 are many moments, that only play if the player looks at them very mid screen, its a nice way to start action with player interaction. In my case I want to implement a figure that looks through a window, when the player looks at it the figure should hide.
Currently I use a VisibleOnScreenNotifier3D for it, but even behind walls the event is fired because its "on screen" even I can't see it. Without a wall as extra challange the event gets fired with the first pixel on screen if you turn slowly the animation is already played till it would end on screen.
A other test used a collision box but result is bad because its fired by distance more or less on screen. It would need to be a truncated pyramid to be able to say that the event only should start if the inner 50% of the screen.
In a perfect world I want 3 areas on screen:
inner 10% around the crosshair events plays immediately
10 to 50% events plays after 2 seconds
and 50 to 80% screen events starts after 10 seconds.
What would be the correct way to implement this?
Is there a need to implement it by hand (calulate it by looking angles and sightlines)?
Why is there no collision shape that forms a nice cone or truncated pyramid?
Maybe its performance reason but implenting it by hand would need a lots of trigonometry as well per frame and event zone. Example: https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
To get the distance from event object to the viewing direction, Then check if the closes point to the viewing direction is inside of the min and max distance of the viewing cone.
Then using that point on the line and the point of the object to calulate if its inside of a cone
"ax+b<c" to just start the trigger. With a the pov angle and b is the amount of screen it has to be in and c is the distance between point on line and the event point.
Writing this I had a even worse Idea having 2 or more viewports with different sizes so the event plays only if seen on viewport 2...
Hi, I've been banging my head against a wall on this for a few hours. I've consulted the documentation and haven't been able to figure this out.
I'm creating a tower defense game with a random path generator. I want to use the path that is generated to define the Curve2D within a Path2D, and then attach a PathFollow2D to that Path2D to have the enemies follow the PathFollow2D. I have done these steps, but the actual movement of the enemies is scaled totally different than what the coordinates of the Curve2D say it should be.
Here's a screenshot of the enemy (top left) not spawning at the beginning of the path or following the path. I have checked the code and the Curve2D for this sprite matches the coordinates of the road in the image.
Any help and thoughts would be really appreciated! Thank you!
Edit: Some of the indenting is showing up wonky below, not sure how to format code properly. But that is def not causing this issue :D
Here's my code:
extends Node
# SETUP
@export var map_length:int = 16 * 5
@export var map_height:int = 8 * 5
@export var mob_scene:PackedScene
var _generated_path:PathGenerator
var enemy_curve = Curve2D.new()
var enemy_follow = PathFollow2D.new()
@onready var enemy_path = get_node("Mob/MobPath")
# Called when the node enters the scene tree for the first time.
func _ready():
_generated_path = PathGenerator.new(map_length, map_height)
_display_path()
_complete_grid()
# Add path points from path to Curve2D
for coordinate in _generated_path.get_path():
enemy_curve.add_point(Vector2(coordinate.x, coordinate.y))
# Set the defined curve to the Path2D
enemy_path.set_curve(enemy_curve)
enemy_path.add_child(enemy_follow)
# Add Sprite to PathFollow2D
var sprite = Sprite2D.new()
sprite.texture = load("res://assets/Enemies/tank_blue.png")
enemy_follow.add_child(sprite)
func _process(delta):
var speed = 100
enemy_follow.progress_ratio += (speed * delta) / enemy_curve.get_baked_length()
# CREATE ENEMY PATH
func _display_path():
var _path = _generated_path.generate_path()
var map = get_node("Base")
while _path.size() < 35:
_path = _generated_path.generate_path()
for element in _path:
var vector = Vector2i(element.x, element.y)
var score = 0
score = _generated_path._get_tile_score(vector)
if score == 1 or score == 2 or score == 4 or score == 12:
map.set_cell(0, vector, 0, straight_horizontal)
elif score == 3:
map.set_cell(0, vector, 0, straight_vertical)
elif score == 5:
map.set_cell(0, vector, 0, corner_right_down)
elif score == 9:
map.set_cell(0, vector, 0, corner_left_down)
elif score == 6:
map.set_cell(0, vector, 0, corner_right_up)
elif score == 10:
map.set_cell(0, vector, 0, corner_left_up)
else:
print("PROBLEM PROBLEM" + str(score))
# Debugging
print("tile placed at " + str(vector))
# POPULATE MAP WITH SCENERY
func _complete_grid():
var map = get_node("Base")
for x in range(0, map_length, 4):
for y in range(0, map_height, 4):
if not _generated_path.get_path().has(Vector2i(x, y)):
var rand_tile = randi_range(0,25)
if rand_tile >= 0 and rand_tile < 11:
map.set_cell(0, Vector2i(x,y), 0, grass_tile1)
elif rand_tile > 10 and rand_tile < 24:
map.set_cell(0, Vector2i(x,y), 0, grass_tile2)
elif rand_tile >23 and rand_tile < 26:
map.set_cell(0, Vector2i(x,y), 0, grass_tile2)
var sprite = Sprite2D.new()
sprite.position = map.map_to_local(Vector2i(x,y))
sprite.texture = load("res://assets/Scenery/treeBrown_large.png")
map.add_child(sprite)
I know the answer is probably "nowhere near where you are now". For what it's worth, if it came to this, I would just use the Godot Physics code as a template to duplicate and modify, then figure out how to make that into a plugin
Right now, I have a Momentum Based Run&Gun with game physics system based off CharacterBody2D... BUT that physics involves drag, collisions, density, etc. In addition, EVERY moving entity in the game can be treated as a damage dealing bullet with sufficient speed: players, enemies, pushable objects.
And when I say "momentum based", I mean the game is LITERALLY scripted to obey conservation of momentum whenever two entities slam into eachother
Writing all this stuff in GDScript rather than letting a dedicated physics server work with it, PROBABLY isn't very performant. But trying to use base Godot Physics with base Godot RigidBody could have some uncomfortable quirks to fight against
Here are the things I've currently got implemented that I would want my physics engine to have elegant control over, as well as "bug fixes" for things that have been frustrating for me in the current Godot Physics:
1: Lerp() should have a framerate independent variant, and this frame rate independent variant should be what is called for damping. There's actually a surprisingly simple fix for making something like this:
lerp(source, target, 2^(-rate*delta))
This turns Lerp into a sort of "half life" function: rate 1 means it halves every second, rate 2 means it halves every 2 seconds, rate 0.5 means it halves every half second, etc. The Delta in the exponent perfectly balanced the delta from running it per frame
2: my physics uses an approximation of air resistance along the lines of coeffnet_velocitynet_velocity*mod. Coeff is a Vector2, representing drag for moving along a certain axis of the object.
2a: HOWEVER, that "net_velocity" is there for a reason: some area2D will be setup with Wind or Water Currents, and draggier objects should naturally be pulled along by the wind more easily than streamlined objects.
2b: that "mod" is also related to fluids: some will have higher dragginess than others, tho the relative differences will be smaller than in real life to prevent utter molasses movement
3: along the lines of Fluid Fields, there will also be density for both entities and the fluid: this modifies the effective gravity, where having equal densities results in effectively zero gravity. Having density twice that of the fluid still effectively halves gravity
4: while I DO want to consider friction for things like traction and slowing down, making enjoyable playable characters would require some modifications:
4a: when stationary and player/AI input happens, having a lot of traction should make it EASIER to move along the floor, not harder.
4b: in addition to static, there should be sliding and rolling friction as possibilities
5: something that's been very annoying with character movement is that "get_angle()" obtains its information from the COLLISION normal (which is just the fastest way to uncollide), not the SURFACE normal. That can result in a 5 degree inaccuracy, which may not sound like much, but it IS very annoying.
6: I want to have a "physics_rotation" and "physics_rotation_degrees" parameter. When Rotation is locked for RigidBodies, this parameter can still be influenced, allowing collision shapes and sprites to remain stable while still obtaining information from things like collisions with entities and terrain
7: it should be possible to setup NEGATIVE Collision Elasticity (labeled as Bounciness in Godot): when the result is negative, objects can pass thru eachother, like a bullet passing thru a glass window. This behavior can be toggled, and it still cannot exceed an absolute value of 1.
8: gravity when on the ground should be lower than gravity while in the air, roughly 1/2.
I'm getting this tattooed on my forehead. This single phrase and its explanation have helped me understand signals better than anything else.
Do you join facebook groups or other sub reddits?
The reason why I ask is because I have made a few games that I want to see how bad/good they are. And also talk about some technical parts
Hi! I'm working on 2d sokoban game. I want to add joypad control to be able to also publish it for the steam deck. I managed to implement joypad control in-game (navigation, shortcuts to restart, cancel step and menu), but how to implement control for the rest of UI? Like button selection and click, settings (sliders, dropdowns). And did anyone use joypad with Dialogue Manager?
This is weird. Yesterday I was working in godot completely fine and this morning without any change ( no updates or anything ) godot is unusable. It is starting with the project manager, it is very freezy/laggy and takes a solid minute to get to the point where i can open a a project.
When the project finally opens it is doing the same thing in editor, laggy and freezy, clicking things either doesnt work or takes forever.
I did have a graphics update ready to be downloaded through intel graphics so I tried to install it but the issue is persisting through that update.
also tried downloading the dev7 snapshot for fun, issue persists. forgot to mention im runing 4.3 stable
Any ideas?
I have an AnimatedSprite2D with a ShaderMaterial applied. I want to apply an effect to invert the sprite's colors for a time and then return to normal after a signal is emitted. Using the shader below, I am able to start the inverse effect using a uniform, but if I try to set it back the colors never change.
My Shader:
shader_type canvas_item;
uniform bool applied = false;
void fragment() {
vec4 color = texture(TEXTURE, UV);
if (applied) {
COLOR = vec4(1.0 - color.rgb, color.a);
} else {
COLOR = texture(TEXTURE, UV);
}
The code I use to enable/disable the shader:
if invert_colors:
shader_material.set_shader_parameter("applied", true)
func on_revert_colors() -> void:
print("got signal to turn off color inversion")
shader_material.set_shader_parameter("applied", false)
What am I doing wrong?
Basically where the character walks, it'll paint the ground.
https://reddit.com/link/1hioaqn/video/sskt0r7db18e1/player
I've tried many things and nothing worked sadly, I need something that works with a moving camera and optmized for multiple characters so a viewport and spawning particles/sprites doesn't seem to work.
The best result I had was using line 2d and creating an infinite trail but everytime the character jumps I have to create a new Line 2D node to cut the trail and it's not optimal either.