XIO

xWire

Posts from every feed QUEST has found across the web — blogs, news, podcasts, channels and more.

Godot Forum - Topics tagged gdscript

Topics tagged gdscript

Control DirectionalLight3D rotation in editor via script parameters

Godot Version 4.7.2 Question I have a GDscript attached to a DirectionalLight3D that sets its rotation values at runtime based on date/time/location parameters (see screenshot below). Is it possible to set the rotation values via script directly in the editor? What I would like to happen is to see the light orientation update along with a parameter value change while I’m editing the scene (for example: setting a different hour of the day immediately changes the light orientation) 6 posts - 3…

Binding player nodes and sprite to mouse

Version: Godot_v4.7.2 Hello! I should start by saying I’m an absolute beginner to Godot, as well as programming in general. I’m hoping to gradually teach myself just by searching for stuff online, but I’ve hit my first roadblock. In the game I’m trying to make, I want to have a player scene attached to the cursor and following it seamlessly. This is, I’m assuming, not the most practical way to achieve what I want in the longterm, but I’d like to figure it out as a learning opportunity as well.…

Is the problem in FastNoiseLite or my code?

Godot Version 4.7.stable.mono Question I am trying to make a voxel top down 2d right now. I have done this multiple times before. It is the exact same logic. I am 99.8% confident that it is in the generate_map(). It generates and views in rings. it has worked before, but not in this draft. It is generating odd rings. extends Node var floor_id_map: PackedInt32Array var wall_id_map: PackedInt32Array var wall_health_map: PackedByteArray var floor_health_map: PackedByteArray var map_seed: int var…

Best practices for swapping between multiple SpriteFrames resources

Godot Version v4.7.2.stable.mono.official Question Not new to programming/game design, but new to Godot. As part of learning it, I’m playing around trying to build various things to learn how things work, at the moment trying to build something like a top-down shooter where the player can collect different powerups that leave most of the player’s behavior the same but change the attack/animations they use. One option is to have all the data relevant to powers as a static or defined-on-load…

A weird halo arround camera view when near the ground

Godot Version 4.7.3 Question Hello ! I have some issue solving this problem, there is a low def halo arround my camera when i'm near the ground that appear, it also appear when near an elevation. The halo disapear if i deactivate mipmap, so i'm thinking it have something to do with that. I will try to modify mipmap options and hopefully find a fix but would be happy to know what actually cause this issue. Thank you very much Shader have elevation, is multiple blended textures with normal maps.…

How to create noise image that can be sampled in _draw loop

Godot Version 4.7.2 Question Hi I’m trying to make marching squares algorithm following Coding in the Cabana 5: Marching Squares | Nebula , and I want to make the index values based on noise but I can’t seem to figure out how to sample noise as TheCodingTrain does. They are using Processing, but up to this point I’ve been able to successfully recreate the result in GDScript. As you can see I have already managed to make it based on a random integer of 0 or 1, but the goal is that I’m gonna…

Voxel terrain generation help

Godot Version 4.6.1 Question So around a week ago I watched and followed a whole series about voxel terrain generation and was wondering if I could generate caves. so I tried to do a naive approach and just wing it and I now have an error when trying to run the game and either undo but that means no cave terrain which I cannot have. the problem lies here: func generate_data(chunk_size: int, max_height: int, noise: NoiseTexture3D, color_array: Array[Color]) -> void: for x in range(chunk_size):…

Tuning a card roguelike with a bot: 120 seeded runs per change, and the number that mattered most

Balancing a roguelike by playing it yourself is slow and you get good at your own game, which hides problems. In Full House (a poker-scoring card roguelike template) I use a small bot that plays whole runs instead. It’s deliberately not clever. Here’s how it works and what it showed when I changed some numbers. 1. A greedy bot in three functions Play: try every way to play 1 to 5 cards from the hand, score each one with the real scorer in preview mode, and keep the best. With 8 cards that’s at…

Error: Cannot call method 'start' on a null value

Godot Version 4.6.3.stable Question Trying to add a cooldown to changing the gravity. Whenever change_gravity() is run it causes the error; Cannot call method ‘start’ on a null value. I know that g_cooldown_timer’s value is ‘null’ but I’m not exactly sure what that means aside from that it has no value. I have checked other similar questions, but while they may have had the solution to my problem I --quite honestly-- was not able to apply them to my own code. I have given the Scene Tree and the…

Balatro-style scoring in GDScript: poker hands as data, a fixed scoring order, and charms with no code

Poker-scoring roguelikes look like a pile of special cases: every joker or charm bends the rules a little. Most of that goes away with a few structural choices, so here’s how I structured it in plain GDScript, in case it helps anyone making a card game. 1. A poker hand is a pattern, not a function Instead of writing is_full_house(), is_flush() and so on, each hand type is a resource with two things: a list of same-rank group sizes and two flags. Pair: groups = [2] Two Pair: groups = [2, 2] Full…

Into the Breach style tactics in GDScript: rules as events, previews on a cloned board, and attacks that move when pushed

In Into the Breach style tactics, enemies show exactly where they will strike, and your turn is about pushing them so the attack lands somewhere else. It looks like a lot of special cases, but most of it falls out of a few structural choices. Here’s how I built it in plain GDScript, in case it helps anyone making a grid tactics game. 1. The rules never touch the screen The board is a plain RefCounted class: terrain in an array, units as small data objects, an occupancy lookup. Every rule (move,…

Game feel effects that stack without fighting your code: trauma shake, real-time hit-stop and "apply the difference"

Screen shake, hit-stop and squash are easy to add one at a time and surprisingly easy to break once several play together. Three hits in one frame shake the camera three times as hard, two squashes leave the sprite permanently squished, and a shake that sets camera.offset wipes out the offset your own code set. Here’s the approach I settled on, in plain GDScript, in case it helps anyone polishing a 2D game. 1. Apply the difference, not the value Never write camera.offset = shake. Keep what you…

Thousands of 2D enemies in plain GDScript: flat arrays, a counting-sort grid and MultiMesh

The usual way to make an enemy in Godot is a node: a CharacterBody2D with a sprite and a collision shape. That’s great for a dozen enemies and slow for a few thousand. Here’s the approach I used for a crowd system in GDScript, in case it helps anyone making a survivors-like, tower defense or bullet hell. 1. Data, not nodes Every enemy is an index into packed arrays: position, velocity, HP, type, radius and so on. Moving the whole crowd is one loop over those arrays, with no per-node overhead…

How does this work? Please explain to me

Godot Version 4.6.2 Question func clamp_vector(vector, clamp_origin, clamp_length): var offset = vector - clamp_origin var offset_length = offset.length() if offset_length <= clamp_length: return vector return clamp_origin + offset * (clamp_length / offset_length) I know what it does i don’t know how it works This function clamp position in a circle instead of square 5 posts - 3 participants Read full topic

How do I fix this unknown error

Version godot 4. Question how do I fix these errors. Line 21:Expected “:” after “if” condition. Line 21:Expected statement, found “Dedent” instead. Line 21:Missing unindent at the end of function declaration. My code is. if Input.is_action_just_pressed("flammas spear") and func \_on_hurty_hurter_flamma_area_entered(): var sparta_hp = 0 pass The line the error references is line 21 which is 7 lines past this code this is also the only code in this script. 2 posts - 2 participants Read full topic

im new to programming as a whole, and i need to know how to fix this

Godot Version Godot 4.6.1 Question so, my code is: extends CharacterBody2D const SPEED = 300.0 const JUMP_VELOCITY = -400.0 func _physics_process(delta: float) -> void: # Add the gravity. if not is_on_floor(): velocity += get_gravity() * delta # Handle jump. if Input.is_action_just_pressed("ui_accept") and is_on_floor(): velocity.y = JUMP_VELOCITY # Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. var…

Release: Timberwild, a tree-chopping incremental on Android (Godot 4.7)

Hi all, I’m Mike from This Way Games. Our game Timberwild is out on Google Play, and it’s made with Godot 4.7.2. How it plays: Each run gives you a grove of trees and a fixed amount of stamina. Every chop is a tap, so it’s active, not idle. Logs go to your sawmill and come out as coins. Coins buy nine stats: chop damage, stamina, crit chance, logs per tree, log price, regrowth, queue size, sell speed and delivery. Quests pay tokens for powerups (Meteor, Gold Rush, Berserker), lightning strikes,…

Control Nodes Neighbor Keyboard Navigation

Godot Version 4.7 Question My girlfriend and I have been making a 2D game since late July, and I’m working a lot on the UI right now, to make everything be navigated by a keyboard and a console controller. By just looking at all the Control node properties and docs, I have discovered today that there is a way to link the neighbors in all directions, so you can have an easy keyboard navigation, and I loved that! And overall, it’s working quite well. But there is a big visual problem: for…

Vector2/Vector3 deviation after initialization

Godot Version Godot Engine v4.6.2.stable.official [71f334935] Question I noticed something strange while programming with Vector2 and Vector3: # Example: var vec: Vector2 = Vector2(5.25, 4.69) print(vec) # Output: (5.25, 4.69) # However: print(vec.x) # Output: 5.25 print(vec.y) # Output: 4.69000005722046 This caused some bugs in my game. Especially when I compare the x-values of two vectors and the condition is sometimes true and sometimes false. Depending on weather the x-value is actually…

I'm working on my first game, I what do you think?

Godot Version 4.7.2 My first game! (and saying hi) I’m working on creating this game called Untitled Pirate RPG; if that name is taken or too similar to something, please lmk. This is the starting island so far, and some basic gameplay. If you have any comments or would like to help in any way (especially with 3D models and audio), I would really appreciate it. Since this is my first game (and I plan to finish it), I’m still a beginner, so any skill level is welcome, and I would love different…

Button Node not receiving inputs

Godot Version 4.6.3 Question These buttons nodes that I have a problem with seems to not receive the mouse click or mouse enter/exit input for some reason. There are no other control nodes blocking the screen as I've checked the debugger. The buttons nodes doesn't have the mouse filter as ignore. The other control nodes (that doesn't have the stop filter), even while not visible, still can receive the mouse click input. They do not overlap the buttons I have a problem with. What could possibly…

Getting computed tile map layer physics polygons

Godot Version 4.7 Question I have a class based off of tile map layer. It uses a tileset that has a physics layer on every tile. I use this to detect if any mobs or objects enter the tile map layer. For the objects, I use area2d’s on_body_entered signal to check if they collide with the tile map layer I also want to detect if two tile map layers collide. From what I understand, tile map layers don’t have a behavior similar to area2d’s on_body_entered, so I need to attach an area2D to the tile…

Different references to objects apparently create different objects

Godot Version v4.7.2.stable.official Question I have a list of characters stored in two places. One, inside a state file which can be saved and loaded at will. Two, inside a temporary list of characters for use in a camping scene. I thought that these two different arrays should both be storing references to they same character objects in memory. However, through testing, I have determined that the objects are somehow being duplicated instead of referenced. I hope it’s not necessary to post my…

Godot says my access of index 1 is invalid on a six column packed string array

Godot Version 4.3 Question My packed string array ‘totalarray’ has six columns and six lines on it and it says the index ‘1’ is specifically the one failing. I don’t know if my ‘i’ value is the one wrong or what but when input a fixed number like 6 it work just fine. I tried printing the ‘totalarray’ to see if it was missing columns or rows before it would use the code but nothing changed or was off. Invalid access of index ‘1’ on a base object of type: ‘PackedStringArray’. for i in…

exported godot game crashes out of nowhere

Godot Version Godot_v4.7.2-Stable_Win64.exe Question so when i launch my server.exe which is a dedicated server export. this happens. but when i use the dedicated server tag on actual godot. this doesnt happen. heres the error. before when i exported my game. it worked. even the server.exe. then i went to eat. i came back and this happened. i tried to fix it and even reexported it a few times. ================================================================ CrashHandlerException: Program…

How can i create railroad tracks with uphill/downhill movement and speed changes in Godot 4.6?

Godot Version 4.6 Question Godot Version: 4.6 Question: Hello everyone! I’m currently learning Godot 4.6 and working on my first 2D game. I’m trying to create a railroad track system where a character riding a cart moves automatically along tracks that go uphill, downhill, and through smooth curves. I want the cart to: Move forward automatically without requiring directional input. Follow the railroad tracks, including uphill and downhill slopes. Gradually increase speed when traveling…

Code isn't working on export

Godot Version 4.7.2 Question For some reason my notes aren't moving when the game exports? They work when testing in the editor but not when it's exported to an exe. Heres the code for spawning the notes: var finder = note_times.find(beat) var note = note_nums[finder] var sound = note_sounds[finder] var scene = preload("res://Scenes/note.tscn") var instance = scene.instantiate() $Notes.add_child(instance) And here's the code for the note movement: func _ready(): while true: print("time5") if…

Big Candy RNG Trinket

I gave out candy for the first time, In addition to the small candy we gave out, there were a limited supply of full size candy bars and to make it interesting, I developed this rng trinket game where trick-or-treaters can spin a random number between 0 and 200 to win. The number is random The winning condition is random My son made some art assets to use as well, which includes the candy pictures and the pumpkins bouncing about. itch.io Big Candy RNG Trinket by itzskye A simple rng trinket I…