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

GDScript is a high-level, progressively typed programming language. It uses a syntax similar to (blocks are indent-based and many keywords are similar). Its goal is to be optimized for and tightly integrated with Godot Engine, allowing great flexibility for content creation and integration.

839 questions
15
votes
1 answer

How do I adapt AStar in Godot to platformers?

I've been looking for a robust method of pathfinding for a platformer based game I'm developing and A* looks like it's the best method available. I noticed there is a demo for the AStar implementation in Godot. However, it is written for a grid/tile…
Matthew
  • 768
  • 1
  • 11
  • 25
14
votes
2 answers

Can Godot and GDScript store functions in variables?

I am confused by part of the Godot Docs for the GDScript language. About midway down the page, in the "Referencing Functions" section, it says you can't store functions in variables, and then seems to immediately contradict itself. Can Godot…
LuminousNutria
  • 1,883
  • 2
  • 18
  • 44
13
votes
7 answers

Godot Keyboard Events

I am studying the Godot Engine and GDScript and I searched on the internet about keyboard events, but I didn't understand. Is there something in Godot like: on_key_down("keycode")?
user193464
  • 380
  • 1
  • 6
  • 25
10
votes
1 answer

How do I implement structures in GDScript?

Is there an equivalent of a C# structure/class in GDScript? E.g. struct Player { string Name; int Level; }
Max
  • 434
  • 1
  • 3
  • 13
9
votes
2 answers

How do I get which Control node currently has focus?

I'm trying to determine which Control node has just changed focus. Another Control node has been set up for using focus by changing the focus mode on the node to All. From within that node's script, I can tell if it has focus by checking has_focus.…
Kyle Pollard
  • 2,204
  • 1
  • 13
  • 27
9
votes
1 answer

Godot 3.2.1. Can't change this state while flushing queries. Use call_deferred() or set_deferred() to change monitoring state instead

In my 2D game player has the ability to destroy crates, objects with two collision shapes. When destroyed, crate spawn items that also have collision shapes. But when the following function called many similar errors are displayed in the Godot…
Andrey Kachow
  • 936
  • 7
  • 22
8
votes
3 answers

How to convert global enum values to string in Godot?

The "GlobalScope" class defines many fundamental enums like the Error enum. I'm trying to produce meaningful logs when an error occurs. However printing a value of type Error only prints the integer, which is not very helpful. The Godot…
bluenote10
  • 23,414
  • 14
  • 122
  • 178
7
votes
1 answer

Why do some nodes use "position" and others use "rect_position"?

What's the technical reason for this? It seems strange to me that they can't all just use position. Is it a legacy thing?
Buck Russell
  • 131
  • 1
  • 9
6
votes
1 answer

Using a custom class in Godot

I have a simple network chat program created in Godot that I am using to teach basic encryption to high school students with. I would like to add a custom built encryption class to allow students to create their own cyphers. Here is a simple…
Tristan
  • 153
  • 2
  • 11
6
votes
1 answer

GDScript. How to make your own library in Godot and access it from your game scripts

I wonder how can I create a script, which contains methods I want to use in multiple scripts. I don't think I want to create a global singleton for it, because I am not storing any global data which will be preserved across multiple scenes. I am…
Andrey Kachow
  • 936
  • 7
  • 22
6
votes
1 answer

How do I change sprites in scripts?

I'm trying to make a dating sim as a easy first game programming-wise. I don't know how to change the character sprites inside the scripts. character_sprite.gd extends Sprite var char_tex = load("res://Sprites/Lu2.png") func _ready(): …
Lynn Len
  • 91
  • 1
  • 2
  • 8
6
votes
2 answers

More ideas of how to prevent slope slide down with KinematicBody2D?

I have a basic code below. I am trying that the player not slide down on slopes. My slopes now are 45°. If the player stop movement on slope, it will slide down (maybe because velocity.y += delta * gravity.y). I can get the angle by normal and set…
gcivico
  • 61
  • 3
6
votes
1 answer

Godot engine collision with KinematicBody doesn't work

I was fiddling around with the Godot engine and tried a little game. But I can't seem to get an info on colliding. if is_colliding(): print ("Collision with " + get_collider()) get_node("Sprite").set_texture(walk_cycle_right_1) …
Linuxer4Fun
  • 85
  • 1
  • 6
5
votes
2 answers

How to call a variable from a preload script in godot?

When I make a preload script in godot and put a variable in there, how do I call the variable in my other scripts? Is there a special way to call the variable that I don't know or is there a better way to do it than preload scripts?
Theo
  • 51
  • 1
  • 2
5
votes
1 answer

Godot - How do I create a subarray of a list in Gdscript?

I know it's possible to slice an array in python by array[2:4]. The way I get around this is to just loop through the indexes I want and append them to the new_list. This way requires more work is there just a simple way to do it like in python?
jujumumu
  • 350
  • 4
  • 12
1
2 3
55 56