Questions tagged [gdscript]
GDScript is a high-level, progressively typed programming language designed to work with the Godot Engine. It uses a syntax similar to Python (blocks are indent-based and many keywords are similar).
171 questions
6
votes
4
answers
729
views
In a tile based game, with units that can move a specific amount per turn, how do i make my pathfinding avoid damage unless it is the only valid path?
i am making a 3d tactics game, visually similar to something like final fantasy tactics. it's tile based, with units able to move up and down the level onto buildings and up staircases and what have ...
3
votes
1
answer
2k
views
Is there a way to instantiate a custom class decided at runtime in GDScript?
Can I instantiate a custom class during runtime through a String without knowing the value of the string when writing the code?
Example:
...
0
votes
1
answer
105
views
1
vote
1
answer
443
views
How to take a screenshot beyond the viewport?
I have a large level design & I'm trying to take a pixel perfect screen shot of a particular area and/or the entire map bound within a region like this:
The region can be changed in size and ...
1
vote
1
answer
353
views
Why can't I get the AnimationTree node?
This is my code:
...
2
votes
1
answer
1k
views
Hide Children of Node
I am making a addon for my friends, and I am trying to make a custom node. It works, but I have a problem, the children of the custom node is visible in the scene dock.
The ...
2
votes
1
answer
1k
views
Setting A Panel texture in GDScript
I am messing around with Godot, and I couldn't seem to find a way to set the texture of a Panel node in Godot. First I tried using the ...
0
votes
0
answers
104
views
Pixel platformer character collides with blocks above while there's still a visible gap
I was trying to the set up a tile map for a 2D pixel art game in Godot 4.1 (following a tutorial) and realized that there seems to be an issue or something I am not aware of with the way collisions ...
1
vote
2
answers
918
views
Simple Circuit System
I want to make a simple circuit system in Godot. Here's what I mean by that. (The circuit isn't realistic)
I just want a battery object and a ...
1
vote
1
answer
2k
views
Actual Custom Nodes in Godot
So I am creating a plugin for Godot 4, and I want to create an actual custom node.
What do I mean by that?
First to create a custom node I do:
...
1
vote
1
answer
642
views
Area2D only detecting body_exited once
I am new to game development, I am practicing by creating a pong game.
I currently have an Area2D set up with a signal listening for ...
0
votes
1
answer
3k
views
Curves in Godot 4
I'm trying to figure out how to use curves to ease variable values in Godot 4.
Ok, I've created a curve like this:
@export var test_curve: Curve
I set up my curve ...
0
votes
1
answer
246
views
"Springy legs" for a First Person Controller in Godot 4
I'm a total beginner, so I barely know what I'm doing, but here goes: I'm using this First Person Starter template and I would like to add a "springy legs" feature on character landing. The ...
0
votes
1
answer
179
views
How do I determine which pixel is under the cursor when looking at an equirectangular image through a camera?
I am working on a game. The camera is freely rotatable by the user. The background is displayed from an equirectangular image. I need to know which pixel of the background image is located under the ...
0
votes
1
answer
666
views
How can I change scenes when the player touches another CollisionShape2D in Godot 3.5?
I need to know how I can change scenes in Godot 3.5 when the player touches another CollisionShape2D.
I've tried this:
...
0
votes
1
answer
924
views
Is it possible to do conditional compilation in Godot at this time, via export settings?
In a number of other engines I've worked with, including Unreal and Unity, there's been support for not only preprocessor commands, but conditional compilation based on platform. As an example, in ...
0
votes
1
answer
804
views
Parameter "current->parent" is null, don't see why
I'm using Godot for my current project, and it's been going great; but there's a bug I don't understand. I have a certain very simple script on my title screen:
...
3
votes
1
answer
361
views
How to make a CharacterBody2D slide out of StaticBody2D instead of teleporting?
I am trying to replicate Mario Maker's On/Off switches in Godot 4.1.
In my current version, if the player got stuck inside the block after it was toggled on, the player just teleports out it. I know ...
0
votes
0
answers
274
views
How do I copy GPU buffers in Godot like in Unity?
How would I convert even a section of the following code, which was taken from this GitHub Source to Godot C# or GDScript?
I'm trying to make a Godot version of this project, but I don't know how to ...
3
votes
1
answer
1k
views
How to make a callable type safe?
I can write a function like this:
func foo(someCallableThatShouldReturnBool: Callable):
if someCallableThatShouldReturnBool.call(): # do something
...
1
vote
1
answer
273
views
Scene Doesn't Change After Animation Complete
I'm encountering an issue in Godot 4 with my 2D character where the "Hurt" animation plays correctly when the character's health reaches 0, but the scene does not change as expected. Here's ...
1
vote
0
answers
1k
views
Dialogue Manager Godot 4 Signals
When using the Dialogue Manager addon on Godot, I am trying to run a function to change the sprite of a character. My function look like this under my character script:
...
3
votes
1
answer
262
views
How can I check if `call`, `callv` failed
In Godot, how can I check whether e.g. Call(...) or Callv(...) succeeded or failed?
By failed I mean due to e.g. missing method, ...
1
vote
0
answers
191
views
Sprite2D texture repeat switches from Mirror to Disabled when resizing window
In Godot 4, I set the texture repeat of a Sprite2D to 'Mirror',
When I run the game, it works fine except when I resize the window — then the texture repeat switches to 'disabled'.
Is there a ...
1
vote
1
answer
862
views
Stay Upright Within Rotating Area
I am making a game that takes place in space and I want you to be able to stay upright in a spaceship even if it rotates. I have this set up:
Its a platform and an area that rotates. I have ...
0
votes
1
answer
2k
views
How to assign a Resource Array to a variable in Godot 4?
In Godot 3, you could do this:
export var (Array, Resource) test_variable
I tried to recreate this in Godot 4, but I could not figure out how. This is what I tried:...
3
votes
2
answers
1k
views
How to Y-Sort a multi-tile entity as a single tile?
I am trying to use Y-Sorting on a tilemap tree to Y-Sort the whole tree, but it is Y-Sorting each tile of the tree instead of the tree as a whole:
I have tried adjusting the Y-Sort Origin but that ...
0
votes
0
answers
313
views
Two CollisionShape2D's Overlapping
I am trying to make a game in Godot 4.1.1 and I encountered a problem.
Whenever my player collides with the enemy, their collision shapes overlap and the enemy stays connected to the player.
Here's ...
1
vote
1
answer
2k
views
_ready(): Node not found: "Pivot/Camera" + player falls through the floor
I'm relatively new to Godot 4.0.3. I have two problems which seem to depend on each other so I put both of them into one single question.
I know, these issues have been reported multiple times on ...
0
votes
1
answer
81
views
Testing for creating Party Member Scenes continuously - Able to create multiple but after the first is custom type is not determined
For my quick test to see if I can create multiple combatants for my battles, I would like to be able to continuous create party members/enemies in order to get to the correct amount of combatants ...
3
votes
2
answers
8k
views
How do I create and import a class in GDScript
I would like to create and import a class in GDScript. Here is some non-functional pseudo code to explain what I'm trying to do:
...
0
votes
1
answer
116
views
Loading Custom Resources for Test Cases - Copying the main way and loading in tres files with code
I am at the start of testing my game. I have just loaded in GUT and I am attempting to load some resources so that I can see the players stats and validate that they are initialised.
Basic assert to ...
0
votes
1
answer
135
views
How do i put the enemy in an idle state without breaking everything
very simple logic but my brain is fried for now, so I don't get how to ad the option for an enemy to sometimes just go idle without breaking the entire animation logic... i tried adding a randomized ...
1
vote
1
answer
333
views
Fanning cards in 2D leads to cards continuing to move forever
I'm using this video as guide for my Godot 3.5 project, but for some reason the code does fan the card but also the cards keep moving and spreading forever.
The code:
...
0
votes
1
answer
201
views
1
vote
1
answer
686
views
How can I utilise world generation through chunks (to reduce lag)
I've been working on a 2D pixel-styled survival game(with the Godot Game Engine), from the birds-eye view(not a side scroller like Terraria) - where the world would look like a map if zoomed out.
So ...
0
votes
1
answer
390
views
simplest combat system i can do with code?
This is my actual set up, and for the moment I'm using this tutorial : https://www.youtube.com/watch?v=Mek4XtMhcMs&t=4s
which is one of a kind, never found any other guide on how to make 3D melee ...
4
votes
2
answers
3k
views
How does Godot 4 copy vectors?
I'm an old coder, but a newbie to Godot. I'm using version 4.
I got some unexpected (to me) behavior when I tried this code:
...
0
votes
2
answers
2k
views
How to break out of nested loops?
Is there a way in Godot's GDScript to quickly/easily break out of nested loops?
For example:
...
2
votes
3
answers
897
views
How to implement game speed setting?
In games like Europa Universalis or Hearts of Iron, there is a way to set game speed. This affects how long does e.g. one in-game day take in real-life time.
At first, I thought this mechanism was ...
0
votes
1
answer
639
views
Why does the "ColorRect" created in code not display?
When I try to create a "ColorRect" in code, it doesn't display. It still seems to exist, but I can't see it.
I am expecting to see both the rect created in the editor at ...
1
vote
1
answer
333
views
Making a countdown time readout in Godot 3.1
I wrote this script to design countdown in my game:
...
1
vote
1
answer
1k
views
Callable string as variable
I followed an old tutorial about a card game and, after finishing it, I started removing some code I didn't like or it was simply not compatible with Godot 4.
Anything went fine, except for one thing.
...
1
vote
1
answer
2k
views
Save and load Resource failing with "Error constructing a GDScriptInstance"
I have this specific Resource script:
...
3
votes
1
answer
1k
views
How to implement a function that normally returns a float, but can sometimes fail?
In Godot GDScript, I have a function that returns a float.
Inside the body of the function, I use the built-in method find, that ...
1
vote
1
answer
969
views
See connected signals for instantiated Node while in Debug mode
I'm trying to debug an issue with my game, where the function that should be connected to a signal is not being called. I have a created minimal repro of the situation by:
Create a fresh Godot 4 ...
3
votes
2
answers
2k
views
Define 2D polygon area and check if point is inside at runtime
I'm trying to write a GDScript (using Godot 4) function that creates a new component at a specific Vector2 position. This works quite well with the following code:
<...
3
votes
1
answer
358
views
Utilize type hints over duck-typing for "@export var" for custom resource
I'm going through the "Creating your own resources" steps. Here's an abbreviated version of the demo resource bot_stats.tres and the associated ...
0
votes
1
answer
415
views
How to set a header on a WebSocketPeer?
How to pass custom header information on a Godot4 WebSocketPeer connection?
1
vote
1
answer
423
views
OptionButton dropdown appears behind other control nodes
I'm getting used to Godot 4.0, and I ran into an issue where the dropdown menu from OptionButton draws behind all the other control nodes (or, at the very least, those further down the scene tree).
I ...