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
0
votes
0 answers

the identifier "velocity" isn't declared in the current scope

"the identifier "velocity" isn't declared in the current scope." godot is showing this error in my code: extends KinematicBody2D func _physics_process(delta): if Input.is_action_pressed("ui_right"): velocity.x += 4 elif…
user18037505
0
votes
1 answer

Why is my character not jumping in godot (2D)

According to this video: https://www.youtube.com/watch?v=Mc13Z2gboEk, so far, at 1:02:44, my character is supposed to be jumping, but on my screen it isn't. Here is the code I have for the Player script: extends Actor func _physics_process(delta:…
kal
  • 11
  • 1
  • 2
0
votes
1 answer

Which AnimationPlayer is currently shown in bottom panel Animation?

I'm trying to create my own plugin and I need to figure out which AnimationPlayer node is currently shown in the bottom Animation panel and please do not suggest I use get_selection() because even if I select multiple (or none ) AnimationPlayer…
cak3_lover
  • 1,440
  • 5
  • 26
0
votes
2 answers

Why is it saying i'm misplacing "elif" even though i already have "if" and "else" in the script?

extends KinematicBody2D var velocity = Vector2(0,0) const SPEED = 100 func _physics_process(delta): if Input.is_action_pressed("right"): velocity.x = SPEED $Sprite.play("right") move_and_slide(velocity) …
user17971130
0
votes
1 answer

Checking if key is being held down

I've got a game where you place towers on the map, it's working fine they can click and the towers place the the build mode is set to false. I Want to allow the player to hold shift down then they can place multiply towers then when they release…
Exoon
  • 1,513
  • 4
  • 20
  • 35
0
votes
1 answer

Basic Calculator: How to script a function for deleting digits one by one? (GDScript)

How am I supposed to code a button that deletes digits in a basic calculator one by one? Heres my script so far: https://pastebin.com/xLj2iCHU func _on_BDeleteDigit_pressed(): var numberAdded var numberBefore = $NumberStuffs.get_text() …
Sammy
  • 23
  • 4
0
votes
0 answers

Godot: How to override function from inherited script?

How does one override a function that was defined in a parent script? Here's my parent script: # Object.gd extends Area2D var id = 0 var coords func _ready(): assign_values() func assign_values(): var a = global_position.x var b =…
mandmeier
  • 355
  • 5
  • 16
0
votes
1 answer

Enemy animation problems godot

I have created an enemy for my 2d rpg game in godot but I used AnimationPlayer and don't know how to make my enemy folow me with the right animations onready var sprite = $AnimationPlayer onready var stats = $Stats onready var playerDetectionZone =…
0
votes
0 answers

GODOT - Scene instances created in code can't receive input, nodes added manually can?

this is my first time posting a question here so we'll see how this goes. I've created a scene in Godot which is set up as Area2D | |-AnimatedSprite | |-CollisionShape2D Attached is the following script: func _input_event(_viewport, event,…
0
votes
2 answers

GODOT - how to disable player movement when dialog box is active and reenable it when its inactive

Ok, i'm really bad at coding. I'm especially new to GODOT and am trying to make a 2d game. I've been able to set cant_move to false when dialog is playing, the problem I'm having is making cant_move true again. I don't even know where to put done =…
Ajajajaj
  • 49
  • 9
0
votes
1 answer

How to make Area2D keep track of body entry all the time?

sorry for my bad english. I have a problem. I need to make Area2D keep track of body entered all the time but it did it one time. How i can track this? Code that i tried to use: var hp = 10 var hero_in_me = false func _physics_process(delta): …
NoNaMe
  • 1
0
votes
0 answers

Why is the button first created wrongly then recreated correctly?

Why is this first creating a correctly size button with the correct number but the wrong background colour and text colour and then the correct button(everything) is created and how can I fix it? func _pressed(): var newTile=Button.new() …
user2617804
  • 169
  • 1
  • 2
  • 12
0
votes
1 answer

how do I fix an "invalid get index 'position' (on base: Nil)." error

In Godot I am trying to make a simple space shooter game where the player has to destroy a certain amount of enemies to get to the next level of the game. I am trying to get the enemy's to shoot the player to make the game a bit more fun but I am…
Pluto
  • 1
  • 1
  • 3
0
votes
1 answer

How do I make WindowDialog resizable in godot?

So I've made this menu for my game in godot. I also made this window which shows up when a button is clicked. This window is WindowDialog in godot, and I want the window to be resizeable. However I get an error when I put the code for the window to…
RockZombie
  • 101
  • 1
  • 9
0
votes
0 answers

How do I spawn a window when button clicked in godot?

So I've recently made a start menu for a game I'm working on. And I've made a button which should spawn a window. I already set the window to hide() and I want the button when clicked to change the hide() mode to show() I've done this in my code so…
RockZombie
  • 101
  • 1
  • 9