Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [gdscript]

GDScript is a high level, dynamically typed programming language used to create content. It uses a syntax similar to Python (blocks are indent-based and many keywords are similar).

Filter by
Sorted by
Tagged with
1 vote
1 answer
50 views

Set Cell Not Creating Tiles in Godot

I have a script in GDScript that contains a simple mouse position listener, and a set_cell function that sets a cell. For some reason, when I set the cell on my ...
user avatar
2 votes
2 answers
114 views

How to differentiate between enemy and something else in Godot?

So, I have a simple 3D game with a player, an enemy, and walls. I've figured out how to detect collisions between my player (RigidBody) and an enemy or wall (Static Body). I want to know how can I ...
user avatar
1 vote
1 answer
116 views

Is there a way to globally/uniquely reference a node in another scene?

I'd like events/actions (e.g. pressing a button, defeating a mini-boss, etc.) in one area of the game to affect things (e.g. unlock/open door, enable boss spawn) in other areas that are distinct/...
user avatar
  • 1,115
4 votes
1 answer
1k views

Is there a do-while loop in GDscript?

Is there a do ... while (condition) loop in GDscript? The documentation explains while but makes no mention of ...
user avatar
  • 1,115
0 votes
0 answers
40 views

Unable to change main scene

Very new to this: I am trying to switch my main scene in project settings from World.tscn to Menu.tscn but I am met with this warning. The Menu.tscn works fine and the project is not running while I ...
user avatar
  • 1
2 votes
1 answer
31 views

deleting and re-referencing nodes with $

I want to delete a scene and re-load it. This code would fail later, because the new "CoolScene" has in fact a different name, something like "@NotSuchCoolName@34", and thus it ...
user avatar
  • 143
0 votes
1 answer
77 views

How to print out the properties and methods of a class in GDScript?

I want to print the properties and methods of a class into the console with GDScript. In Python, this can be done with the print(dir(variable)) method. Is there an ...
user avatar
  • 121
2 votes
1 answer
52 views

How can I keep a node in-place while I re-parent it?

I have an object that needs to follow various Path2D paths in my scene. To do this, when it needs to follow a path, I re-parent it to a ...
user avatar
  • 1,115
1 vote
1 answer
278 views

Why is Area2D not detecting collisions?

I am making a sidescrolling shooter and I am working on the shooting mechanism. I have two scenes, one contains a KinematicBody2D with a Sprite, position2D and a collisionshape2D and a second ...
user avatar
  • 45
0 votes
0 answers
41 views

Signal emission problem

I have a simple shoot'em up in space. When enemies collide with missiles, they explode and disappear. I also send a signal (enemyHit) to HUD to update and display the score. I have declared the signal,...
user avatar
1 vote
1 answer
38 views

Godot bake NavMesh not working

I have a layout similar to the official Godot NavMesh example program. It is: ...
user avatar
0 votes
0 answers
56 views

Code doesn't work? I can't move left or right

I am following a tutorial from Zenva and it seems that my code isn't working, it should in theory move left right and jump. ...
user avatar
4 votes
1 answer
1k views

How does a PackedScene work when passed in an exported variable

To my beginner understanding, in order to use a scene saved on the drive, one must first use ResourceLoader.load() to load the scene to acquire a ...
user avatar
2 votes
1 answer
106 views

Godot 3 - When body enters Area2D move Camera2D

I'm totally new to Godot 3 engine. I want a game with static camera, so it can't smoothly follow player. I made an Area2D signal when_body_entered witch teleports main character to next area of map. ...
user avatar
1 vote
1 answer
189 views

_input not called for a node inside a Viewport

I have a scene with two viewports, the "root" viewport and another inside it, like this: ...
user avatar
  • 1,048
-4 votes
1 answer
74 views

an almost failed space invaders project in godot

thats the line Im getting the error on and those line mainly just go away. this is gdscript in godot
user avatar
5 votes
1 answer
403 views

How to make a component solution in Godot (similar to Unity's)

I want to be able to assign multiple scripts to a single node, and have each script become a component. I know there is an asset in the asset library for a component solution: godot-component-system. ...
user avatar
  • 18.1k
1 vote
1 answer
199 views

Why does this variable keep returning to its original value?

In my 2D platformer game, I'm trying to create a button that, when the player or a box is on top of it, opens a door of the same color. Here is the code for the button: ...
user avatar
1 vote
1 answer
133 views

How to compute the points of a CollisionPolygon2D?

Godot v3.3.1.stable.mono.official I am trying to draw a CollisionPolygon2D programmatically but I cannot resize or write the ...
user avatar
5 votes
1 answer
488 views

Is there a way to run a tool script without attaching it to a node in the scene tree?

What I want to do is run a tool script on the editor. The usual way would be to attach it to a scene tree node, but then I'd have to guard it with ifs all over to ...
user avatar
  • 343
3 votes
1 answer
620 views

What is happening during queue_free() process?

From time to time, I encounter a hard-to-reproduce bug with a similar line of code: ...
user avatar
1 vote
2 answers
448 views

How to flip sprite and all collision children of a KinematicBody2D at the same time?

I have tried to use the scale property of KinematicBody2D to flip at the same time the sprite and the collision/area/raycast ...
user avatar
0 votes
2 answers
280 views

How to know if an overriden method calls its super method or not?

Consider this situation, where a Player class inherits from a more general Actor class: Actor.gd ...
user avatar
5 votes
1 answer
694 views

How to disconnect all signals of an emitter?

This a follow-up question of this one I want to disconnect multiple signals before using queue_free(). In docs we have: ...
user avatar
2 votes
1 answer
100 views

How do signals work when queue_free is called?

Consider this setup: * KinematicBody2D (Player) |- Sprite (icon.png) |- VisibilityNotifier2D With Player.gd: ...
user avatar
1 vote
1 answer
40 views

Traversing an acyclic binary tree to construct paths from a given starting node, but the paths come out wrong

The tree is an acyclic binary tree. It's composed of node objects that have a list of connections to link objects (at most 3), and link objects that have a list of connections to node objects (always ...
user avatar
2 votes
1 answer
451 views

What is the efficient way to sync TextureProgress with a Timer not in the UI?

I want to use a TextureProgress which reflects the state of a Timer. I have tried to emit signals: FROM: the Node2D._process() ...
user avatar
1 vote
1 answer
192 views

How to inherit of a scene tree structure in a way that a change in the ancestor is updated in the descendant?

Consider this structure: * KinematicBody2D (Actor) |_ AnimationPlayer (able to make a rotation of 360) Now I want to make a Player and an Enemy that inherits of ...
user avatar
1 vote
1 answer
137 views

Godot C++ NativeScript version not rendering multimesh instance whereas GDScript version does

I am new to Godot. I am aiming to create a RTS game with 10's of thousands of units and for it to run smoothly. So I'm looking to use GDNative C++ with the Visual Server to handle updating and moving ...
user avatar
  • 141
2 votes
2 answers
395 views

Is it better to connect signals in source code or with the IDE feature?

In Godot IDE, what are the advantages and the caveats of using the visual IDE to connect signals to listerners instead of doing this: ...
user avatar
1 vote
1 answer
258 views

How to make two keys pressed to make an action?

Hey i am beginner gamedev. I couldn't find answer to this or I am bad articulating my problem. But really would like an answer to this. How can i make function to press two keys like A and D at the ...
user avatar
3 votes
2 answers
178 views

Why is my jump arc preview inaccurate?

I'm trying to draw an arc out of dots that previews a KinematicBody2D's trajectory after a jump but said preview always falls short of the body's actual jump and I cannot figure out why. Below is an ...
user avatar
1 vote
1 answer
784 views

Change 3D Render Resolution in Godot

I'm making a Mario-Like platformer in Godot, and am going for a N64 style, and I want to lower the resolution of the render, while still having the window being resizable, like in Blender. Is there ...
user avatar
  • 13
1 vote
0 answers
87 views

How to give node sillouhette when behind wall in Godot

I am working on a boss-rush fps game. I want it to be like the eye of cthulu fight from terraria, with the enemy flying towards you and then turning around to try again if it misses. However, in order ...
user avatar
2 votes
3 answers
592 views

Godot / GDscript label text not updating every frame like intended

I am very new to Godot and coding in general, so I apologize in advance for any simple mistakes. I am trying to have my text display the variable ammodisplay on my ...
user avatar
  • 21
0 votes
1 answer
126 views

How can I handle hundreds of calculation heavy nodes at the same time?

I'm currently trying to implement a basic boids simulation with godot in c#. Currently I managed to implement evasive behavior which works fine for a boid count of roughly 300. Everything beyond that ...
user avatar
1 vote
1 answer
211 views

How do I generate platforms in a specific position in godot?

I am making a rogue-like game in Godot. Currently, I am stuck with the world generation. I know how to add children, but I am wondering if there is a way to add those children in a specific position. ...
user avatar
0 votes
1 answer
210 views

POST HttpRequest doesn't send any data

I've some trouble for sending a post request to my nodejs server. I can receive data from the server with GET method, but when I try to send data with POST, I've an empty bracket on return on this ...
user avatar
  • 1
1 vote
0 answers
76 views

How to redraw the node canvas when the zoom changes on the Godot editor?

I have an addon that extends EditorPlugin and a companion script attached to a node. The companion script draw a rectangle with a size stablished by an exported ...
user avatar
  • 971
1 vote
2 answers
951 views

How to transfer the player into a new scene, loaded in the background?

I'm porting an old BuidBox 2 game to the Godot game engine. I already added all assets and scenes to the Godot project. The game is a 2.5D (isometric) endless runner. What I want now is to add a ...
user avatar
  • 971
0 votes
1 answer
96 views

How should bullet reflections be implemented?

I'm working on a tank game where bullets are reflected off of walls. The formula for a reflection is: $$ r=d−2d⋅n∥n∥2n $$ where \$d\$ is the incoming vector and \$n\$ is the normal of a wall. My ...
user avatar
  • 35
1 vote
0 answers
49 views

Drawing a line between 2 vectors

I was trying to implement a simple mechanic by drawing a line between the sprite and the mouse, but it's not working that well: ...
user avatar
1 vote
1 answer
377 views

Why isnt setting the global_position working?

Previously my items were relative to the player by node hierarchy. But for items like bombs this is not ideal so i tried to add the items to the world scene, but when i try to adjust the position of ...
user avatar
  • 35
1 vote
1 answer
410 views

How should I implement stair climbing?

Im using raycast to detect if a block is to my side. I can use raycast to see if i need to climb stairs but the transition is bad. I immediately reach the top of the stairs when trying to go on them....
user avatar
  • 35
2 votes
1 answer
92 views

Vector2 distance_to weird results

I'm using Vector2.distance_to to get the distance between a MeshInstance and a KinematicBody but the results aren't as expected. I'm using ...
user avatar
0 votes
0 answers
49 views

How to play somersault animation during jumping at top point like in Contra games in 2D game (godot, gdscript)?

Here is my jumping code: ...
user avatar
  • 231
0 votes
1 answer
656 views

Getting Parser Error: The identifier "delta" isn't declared in the current scope. in godot

this is the whole code ...
user avatar
  • 1
2 votes
0 answers
521 views

Godot 3.2 atlasTexture not creating any texture atlas

When I try to use the new feature of godot that lets you import sprites as an atlasTexture, I dont' get any results.
user avatar
0 votes
0 answers
490 views

How to make a 2d game with Ascii art assets

I am new to game development and have been practicing programming games in godot. I am looking to make a minimalist game that uses simple ascii art however I am unsure if I should use UI elements to ...
user avatar
0 votes
1 answer
440 views

Godot - Get button node in click event not working

How we can get the button reference on the event function that is connected? My connect signals never works ...
user avatar