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
5
votes
1 answer

Godot - making labels on demand, and setting their font size with GDscript

Not to over explain, I basically need to create an unknown number of Labels, with unknown text. All fine and dandy - works. I can't seem to find how to change their font size though. Here's what I have: for string in string_list: var new_label =…
TopCat
  • 53
  • 1
  • 4
5
votes
2 answers

Godot make item follow mouse

I am making a 2D platformer in Godot 3.0 and I want to have the player throw/shoot items using the mouse to aim (similar to bows and guns in Terraria). How would I go about doing this? I am using gdscript.
5
votes
1 answer

How do I setup the esc key to exit Godot Application?

I have a question about something I'm getting stuck on with a new 2D project. I added a sprite background and it shows no problem when I run the test. I setup the esc key as "key_exit" in the Input Map. Then I created a node2D as the root and added…
Matthew
  • 768
  • 1
  • 11
  • 25
4
votes
2 answers

How to remove all punctuation from a string in Godot?

I'm building a command parser and I've successfully managed to split strings into separate words and get it all working, but the one thing I'm a bit stumped at is how to remove all punctuation from the string. Users will input characters like , . !…
Hidden
  • 63
  • 2
4
votes
1 answer

Godot: Cannot get path of node as it is not in a scene tree

I have a problem with Godot (I'm learning it). I have a project with 3 scenes, in each there are nodes with attached scripts, shown bellow. Main.gd extends Node2D var maquina func _enter_tree(): maquina = Maquina.new() …
Fahed
  • 195
  • 2
  • 10
4
votes
0 answers

Godot 3.4.4 How to stop audio in html export?

There was a problem with audio playing in the exported instance of the game. The sound is played using the AudioStreamPlayer node. I export the game to html5 and run it either on a local server or on any service that executes html code. If during…
4
votes
2 answers

Godot 4.0. how stop a auto call SceneTreeTimer?

I have this code : extends Area2D func _ready() -> void : auto_call() func auto_call() : await get_tree().create_timer(1, false).timeout print( "area autocall" ) auto_call() func stop_auto_call() : auto_call = null # how…
user70587
  • 63
  • 4
4
votes
1 answer

How to convert a string to enum in Godot?

Using Godot 3.4, I have an enum setup as: enum { STRENGTH, DEXTERITY, CONSTITUTION, INTELLIGENCE, WISDOM, CHARISMA } And I would like to be able to make the string "STRENGTH" return the enum value (0). I would like the below code to print the…
Nathan Headley
  • 152
  • 1
  • 13
4
votes
2 answers

How can I detect mouse input on an Area2D node in Godot (viewport and shape_idx error)?

After testing out a few other engines I've settled into Godot for my game development learning process and have really appreciated the conciseness of GDScript, the node/inheritance structure, and the way observer events are covered by signals. I've…
Sean Simon
  • 43
  • 1
  • 5
4
votes
1 answer

(Godot Engine) Merging more than two polygons using Geometry's merge_polygons_2d() Method

Considering the following scenario: given an n number of Polygon2D nodes that act like "shadows" (black color with halved alpha value), how to combine all of them into an single Polygon2D node using the merge_polygons_2d() method? An example of 3…
KanaszM
  • 151
  • 9
3
votes
1 answer

How to implement a composable character/skill system in the Godot 4.0 Game Engine?

I am currently experimenting with a prototype for a MOBA style game using Godot. I am struggling to figure out a way to manage the characters and their skills. All characters will have similar attributes (Name, health, run speed, strength and so…
Martin
  • 5,954
  • 5
  • 30
  • 46
3
votes
1 answer

How to load game data when restarting a godot4 game?

you know how in games, it saves your data(progress). How do you do that in the godot4 engine? The only way I know how to store data is using variables, but it gets reset when you re-launch the game. Does anyone know anything about this that can…
Coding_Guy
  • 160
  • 9
3
votes
1 answer

【godot 2d】jumping enemy jumps opposite direction of where player is at

I am in the process of developing a 2D enemy that emulates the behavior of a slime, specifically jumping towards the player. I have been able to successfully implement this feature. However, upon further testing, I have observed that while the first…
DeruDeru
  • 65
  • 5
3
votes
1 answer

Proper way to instanciate class in godot (preload vs class_name)

As far as I am aware there are two main ways to instantiate class in gdscript 2.0. Preload/load class with script and create instance: var some_class = preload("res://SomeClass.gd") ... var instance = some_class.new(...args) Use class_name # in…
iwek
  • 348
  • 4
  • 14
3
votes
1 answer

How to set and get position of an Object in Godot (3D)

I have a question - how do I get and set the position of object in Godot? I couldn't find any tutorials, so I need help.
ColorfulYoshi
  • 89
  • 1
  • 2
  • 9
1
2
3
55 56