/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
This appears to be 100 % reproducible, and I'm not sure why it happens or how to fix it:
VBox
, HBox
, or Grid
).Control
children for it.Button
(in an AspectRatioContainer
, breaks either way).This is how it works if I add the buttons directly into the container node, just like you'd expect: https://i.imgur.com/fn294DZ.png
And this is how everything breaks if I add a Control
middleman between the button and the container: https://i.imgur.com/I8k7MuD.png
As you can see, all the buttons are shifted up so that the topmost goes out of the screen completely and the bottom most is not inside the bottom control that I have selected.
I've already tried messing with the Fill and Expand settings of each node to no success.
The reasons I want to use base Control node in the first place is because I want to hide the "implementation detail" of it being a Button
(or an AspectRatioContainer
) specifically, as this part could (and probably will) change in the future when my game grows. Some ways this shows itself is:
Tile
in their scene tree when they create a new instance of it, without hiding any of the details of its implementation.Furthermore, I highly believe this should be not only possible but trivial thing to do, regardless of my specfic reasonings.
Am I missing something and it's actually trivial?
Or am I missing a design principle of Godot engine's and trying to do something I shouldn't be?
Or is there just a bug here?
Thanks to the Godot devs for this engine. I've been doing amateur game dev for a while but this is the first time I've felt really good about the thing I've made, and loving the tools I use to build it has truly been a huge part of that.
Here's my video:
https://www.youtube.com/watch?v=g88sXsq8Z-U
I had a LOT of trouble getting an answer, but at last, I found the answer, and it fixed it. Hope everyone, if your a beginner or not. I hope you find this useful!
I'm new to Godot and I'm about to give up on my Godot project, since I don't know how to do it, and no one has been able to explain it to me or I don't know if it's really possible. I want to share an animation with several objects. I have a piano and I want to put animations on that piano when pressing the keys, but I don't want to make an animation for each key, but rather make it so that the animation for key 1 can be reused on key 2. But I don't know what else to do. Does anyone know how to do it? Please explain it to me or give me a tutorial, or the code.
Godot Version 4.3
How can I make my character take damage continuously if enemy body entered and never exited HurtBox? I’ve struggled and looked at a number (like might be 6hrs of research). I’ve only started learning coding and godot last week.
Here’s my PLAYER script:
extends CharacterBody2D
signal player_hit
u/export var max_health: float = 100.0
u/export var speed: int = 1000
var current_health = max_health
func _physics_process(_delta: float) → void:
var direction = Input.get_vector(“left”,“right”,“up”,“down”)
velocity = direction * speed
move_and_slide()
func _on_hurt_box_area_entered(area: Area2D) → void:
print(“Player hurt”)
if area.get_parent().has_method(“get_damage_amount”):
var node = area.get_parent() as Node
current_health -= node.damage_amount
print("Player Health amount: ", current_health)
and ENEMY script:
extends CharacterBody2D
u/export var max_health: float = 5.0
var speed: int = 100
var current_health = max_health
u/export var damage_amount = 1.0
u/onready var player = get_node(“/root/Level/Player”)
func _ready() → void:
current_health = max_health
func _physics_process(_delta: float) → void:
var direction = global_position.direction_to(player.global_position)
velocity = direction * speed
move_and_slide()
func _on_hurt_box_area_entered(area: Area2D) → void:
pass
#print(“Enemy Hurtbox area entered”)
#if area.get_parent().has_method(“get_damage_amount”):
#var node = area.get_parent() as Node
#current_health -= node.damage_amount
#print("Health amount: ", current_health)
func _on_hit_box_area_entered(area: Area2D) → void:
print(“Enemy area entered”)
func _on_hit_box_body_entered(body: Node2D) → void:
print(“Enemy body entered”)
func get_damage_amount() → int:
return damage_amount
The enemy only damages the player once when its body hitbox the hurtbox. I have the hitbox and hurtboxes in the player and enemy bodies. Thanks in advance!
PS - I also have this issue where when the enemy body collides with the player, it sticks to the player body and never lets go lol. its a mess
Hello community, I've been working on my 2D side scroller, player controller for about a month now, building it from scratch with what I learnt from Brackeys tutorial and my limited knowledge on godots many features. It's going really good and I'm learning alot and making lots of mistakes which is good!
Does anyone have any recommendations for a good resource of player controller code examples. Looking for basic kind of concepts to see how other people handle basic attacks and movements like rolls and jumps etc that I can hopefully learn from and maybe even recreate.
Are there any articles (academic preferable since I'm doing a technical project) on the history of GDScript or studies on its capabilities, inner workings, etc.
If I use mipmaps on high resolution sprites and zoom out with my 2D camera, do they still work the same as in 3D? Also, do they work with tilemaps?
How do I use functions from other scripts in a seperate script?
Invalid access to property or key 'transform' on a base object of type 'null instance'.
var gravity = 9.8
u/onready var head = $Head
u/onready var camera = $Head/Camera3D
func _ready():
Input.set\_mouse\_mode(Input.MOUSE\_MODE\_CAPTURED)
func _unhandled_input(event):
if event is InputEventMouseMotion:
head.rotate\_y(-event.relative.x \* SENSITIVITY)
camera.rotate\_x(-event.relative.y \* SENSITIVITY)
camera.rotation.x = clamp(camera.rotation.x, deg\_to\_rad(-40), deg\_to\_rad(60))
func _physics_process(delta):
\# Add the gravity.
if not is\_on\_floor():
velocity.y -= gravity \* delta
\# Handle Jump.
if Input.is\_action\_just\_pressed("jump") and is\_on\_floor():
velocity.y = JUMP\_VELOCITY
\# Handle Sprint.
if Input.is\_action\_pressed("sprint"):
speed = SPRINT\_SPEED
else:
speed = WALK\_SPEED
\# Get the input direction and handle the movement/deceleration.
var input\_dir = Input.get\_vector("left", "right", "up", "down")
var direction = (head.transform.basis \* transform.basis \* Vector3(input\_dir.x, 0, input\_dir.y)).normalized()
if is\_on\_floor():
if direction:
velocity.x = direction.x \* speed
velocity.z = direction.z \* speed
else:
velocity.x = lerp(velocity.x, direction.x \* speed, delta \* 7.0)
velocity.z = lerp(velocity.z, direction.z \* speed, delta \* 7.0)
else:
velocity.x = lerp(velocity.x, direction.x \* speed, delta \* 3.0)
velocity.z = lerp(velocity.z, direction.z \* speed, delta \* 3.0)
\# Head bob
t\_bob += delta \* velocity.length() \* float(is\_on\_floor())
camera.transform.origin = \_headbob(t\_bob)
\# FOV
var velocity\_clamped = clamp(velocity.length(), 0.5, SPRINT\_SPEED \* 2)
var target\_fov = BASE\_FOV + FOV\_CHANGE \* velocity\_clamped
camera.fov = lerp(camera.fov, target\_fov, delta \* 8.0)
move\_and\_slide()
func _headbob(time) -> Vector3:
var pos = [Vector3.ZERO](http://Vector3.ZERO)
pos.y = sin(time \* BOB\_FREQ) \* BOB\_AMP
pos.x = cos(time \* BOB\_FREQ / 2) \* BOB\_AMP
return pos
I have a label in front of a button. How can I make it so the mouse clicks on the button through the label, or put the button in front of the label but have it invisible and still active
Hi all, I'm trying to implement that when I pick up an object it swings like a pendulum with the mouse's movement. There's a diagram attached (really shitty one, sorry) to try and demonstrate what I'm trying to achieve. I've successfully implemented the click and grab with the sprite animations I want, I just am having trouble with the physics side of things. I've been toying around with a characterbody2d and a rigidbody 2d but am unsure on which would be better/easier to implement this on.
I essentially want to, in the physics process, set the rotation of the object (the rotation pivot is at the mouse cursor already) I'm just not exactly sure how to go about this to get my desired effect. I've also attached a video of what the project looks like right now with broken physics to help visualize.
https://reddit.com/link/1ifkg8z/video/5z0mteppamge1/player
I been looking for tutorials but they're no help.
Here's the code.
Debuted of our game, EOPRISM, at Super MAGFest this past week. We're a few months into development and is available to wishlist on Steam now!
Hi.
Does anyone know of a good guide, or has any information, about how lighting from retro fps like Quake (or more recent ones like Dusk) can be done in Godot? Is it only Omnidirectional lights, or is it a mix of Omni lights and some other light sources (ambient, emission, global illumination, etc.) ?
I am not looking for a exact recreation, just an idea of the basic light mix that I could use in Godot to recreate something similar.
So I've been trying to make a scalable interaction system for a few weeks now and I keep running into problems. I can't find anything consistent on the internet either. I'm new to programming, and very new to Godot, so bear with me if this is something super simple.
I want to have a first person character interact with 3d objects using a raycast. There would be multiple different types of interactable objects that do different things (Item you can pick up, Door you can open, Trunk you can 'dump' Items into).
My first iteration of an interaction system went like this:
And for the main interaction script:
This worked great for a while. I knew having a bunch of if statements wasn't the best way to do it, but it worked. Up until this point how the game played was you'd pick up Items, and then go dump them into a car's Trunk. The Trunk was just an Area3D you would walk into.
Problems started occurring when I wanted to make the Trunk interaction the same as the Item and Door interaction (Aim crosshair on the Trunk and press E to interact with it to deposit items, as opposed to walking into an Area3D).
Things started to get messy and I knew having a bunch of if statements isn't good. So, I've been trying to figure out a better method. And I cannot find anything, or get any help. (Which is why this post is so extensive)
I thought about using has_method(""). This seemed okay, but what if the collider doesn't have the method? Then there's no error and you have no clue why it's not working. Plus, if you ever change the name of the method it will break, etc etc. Did not seem right.
I thought about using groups, but that didn't seem right either. Make an Item group, a Door group, a Trunk group, and check if the object is in group item/door/trunk...... anddd I'm basically just checking a bunch of if statements again.
Okay, so what about using nodes and have a component-like approach like how Godot intends? Sounds fantastic. So, for Items you can pick up, just attach a Pickupable node to them. This node can hold the script that handles what happens when you pick up an item as well, even better. And Doors can get an Openable node.. right? Sounds good so far, but do you just loop through each child of the raycast collider every time to check what component the collider has? That doesn't sound right.
And how do you check if the object you're colliding with even is interactable in the first place? What if it's colliding with the floor or a wall, are you looping through the children of every object you collide with??
At this point my brain is fried, I feel very stupid, and I'm sure I'm overlooking some things that are probably pretty simple. I need the system to be pretty broad, because I'll have a bunch of different Items that will all have different models and textures, different prices and weights, but all basically have the same function for picking them up (queue free them, play some particles, add the price to what's being carried, etc etc). Same thing for Doors.
When I move around with my player controller or even in editor my models will rapidly jitter at the seams of the model. Has anyone encountered this before? I am pretty new to the engine if you can't tell by the crapper minecraft placeholders lol.
I'm making a game that takes place underwater, I've already got a little shader set up that affects the camera when you're underwater, changing the tint, blurring a little, and creating some warping effect. However, my game takes place deep underwater, where I don't want you to be able to see too much around you and for the surrounding area to be dark unless there are nearby lights. Is there anyway to do this? Should I just make a depth blend in my shader and not worry about the specifics?
This is my first time doing something like this, and I don't entirely know what to do or how to even search for what I'm trying to do. Any tips? This is the current shader I'm using for the underwater camera.
Hello! As the title says. I am a complete beginner following a tutorial by Rapid Vectors. At 9:51 he clicks on the "TileMap" button at the bottom. But I do not see it on my own screen. Am I doing something wrong? Or is this due to version differences?