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).

Filter by
Sorted by
Tagged with
0 votes
0 answers
45 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 ...
JAL's user avatar
  • 1
1 vote
2 answers
408 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 ...
TheJalfireKnight's user avatar
1 vote
1 answer
64 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: ...
TheJalfireKnight's user avatar
1 vote
1 answer
281 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 ...
zeroparity's user avatar
0 votes
0 answers
58 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 ...
ThetaJones's user avatar
0 votes
1 answer
90 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 ...
ThetaJones's user avatar
0 votes
1 answer
48 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 ...
Matthew Carson's user avatar
0 votes
1 answer
41 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: ...
shadowxstrike's user avatar
0 votes
1 answer
67 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 ...
Michael Macha's user avatar
0 votes
1 answer
67 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: ...
Michael Macha's user avatar
3 votes
1 answer
67 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 ...
Jason O'Neil's user avatar
0 votes
0 answers
124 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 ...
Ethan's user avatar
  • 145
2 votes
0 answers
89 views

How to make a callable type safe?

I can write a function like this: func foo(someCallableThatShouldReturnBool: Callable): if someCallableThatShouldReturnBool.call(): # do something ...
Kutub Gandhi's user avatar
1 vote
1 answer
70 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 ...
Askani's user avatar
  • 111
1 vote
0 answers
159 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: ...
TheJalfireKnight's user avatar
3 votes
1 answer
72 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, ...
geekley's user avatar
  • 133
1 vote
0 answers
61 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 ...
Shahzaib Hassan's user avatar
1 vote
1 answer
119 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 ...
TheJalfireKnight's user avatar
0 votes
1 answer
280 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:...
TheJalfireKnight's user avatar
3 votes
1 answer
159 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 ...
TheJalfireKnight's user avatar
0 votes
0 answers
64 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 ...
TheJalfireKnight's user avatar
1 vote
1 answer
451 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 ...
EarthAndMoon's user avatar
0 votes
1 answer
46 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 ...
BoydyBoydy's user avatar
2 votes
2 answers
1k 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: ...
Seph Reed's user avatar
  • 225
0 votes
1 answer
43 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 ...
BoydyBoydy's user avatar
0 votes
1 answer
63 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 ...
Cei's user avatar
  • 863
1 vote
1 answer
139 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: ...
Progs's user avatar
  • 93
0 votes
1 answer
95 views

How to prevent accidental double-tap dodge when changing directions?

...
Cei's user avatar
  • 863
0 votes
0 answers
40 views

Scared enemies run into walls

I set up a basic pyramid shaped enemy kinematic body that runs away from the player when its health is too low and runs towards the player if the enemy has enough health. The enemy also turns to face ...
Cei's user avatar
  • 863
1 vote
1 answer
108 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 ...
Apex's user avatar
  • 11
0 votes
1 answer
154 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 ...
Cei's user avatar
  • 863
3 votes
2 answers
846 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: ...
Adam Smith's user avatar
0 votes
2 answers
316 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: ...
BWPanda's user avatar
  • 101
2 votes
3 answers
260 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 ...
jakub's user avatar
  • 123
0 votes
1 answer
184 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 ...
Programmer S's user avatar
1 vote
1 answer
148 views

Making a countdown time readout in Godot 3.1

I wrote this script to design countdown in my game: ...
Nina Monti's user avatar
1 vote
1 answer
390 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. ...
Life after Guest's user avatar
1 vote
1 answer
441 views

Save and load Resource failing with "Error constructing a GDScriptInstance"

I have this specific Resource script: ...
Jeroen's user avatar
  • 545
3 votes
1 answer
389 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 ...
Life after Guest's user avatar
1 vote
1 answer
284 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 ...
Jeroen's user avatar
  • 545
2 votes
2 answers
581 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: <...
Jeroen's user avatar
  • 545
3 votes
1 answer
191 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 ...
Jeroen's user avatar
  • 545
0 votes
1 answer
190 views

How to set a header on a WebSocketPeer?

How to pass custom header information on a Godot4 WebSocketPeer connection?
Victor Lee's user avatar
1 vote
1 answer
118 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 ...
Freswinn's user avatar
3 votes
1 answer
587 views

Equivalent of RigidBody2D's body_exited on StaticBody2D?

I'm building a type of Pinball game using Godot 4.0. I've got two types of components relevant to this question: balls, represented as a RigidBody2D scene with <...
Jeroen's user avatar
  • 545
1 vote
1 answer
132 views

Notification function doesn't work as intended in Godot

I have a situation where _notificaion doesn't work as intended. I have three scenes: game scene (named Puzzle), main menu scene (...
MAGS94's user avatar
  • 157
2 votes
1 answer
755 views

Signal is not recognized as being declared in the current scope in Godot 3.5

I'm learning to use the Godot Engine (v3.5) along with the GDScript. I'm following the official tutorial for the same. In the step-by-step tutorial for the "Dodge the Creeps" game, there is ...
senSMEM8's user avatar
0 votes
0 answers
108 views

How can I debug a y-sort clipping issue?

OS: Mac Godot 3.5.1-stable Language GDScript I have created a Level object as a YSort. Under it I have a ColorRect, 2 Tilemaps, a Tree Scene, and the Player. The tree scene is composed of a ...
Doug Noel's user avatar
  • 101
0 votes
1 answer
769 views

Need a button to reset the scene in Godot

I need to make a button that restarts the scene. i tried func reset(): if Input.is_action_just_pressed('reset'): get_tree().reload_current_scene() But ...
orten's user avatar
  • 1
0 votes
1 answer
197 views

How can I draw a trajectory of an orbit?

With the following code, I either get a straight line or no line at all. I have tried almost the same thing in Unity and I get something that looks like orbiting, but here I get nothing. How can I fix ...
Joshua Bookout's user avatar