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

Working on an Entity and Event Component System

Hello! For the past few days I’ve been on a quest of making a personal “Addon” for godot that I can use for my own projects, the addon in question is an Entity and Events Component system Very inspired by the Synchroni API for Crypt of the NecroDancer’s official modding tools. The main concepts are like: Game Objects are just holders for the components. Components exclusively call events and store data. Events “replace” signals, events are just methods that take in 1 dictionary with all of the…

Relationship Web: NPCs who remember, with love, grudges, jealousy and families

I wanted villagers who remember: who helped them, who wronged them, who they’re sweet on, and who they’ll never forgive. So I built the relationship layer as an addon. Feelings each way between every pair (affinity, trust, familiarity, romance, attraction), so a crush or a grudge can be one-sided Personality traits and attachment styles that change how feelings move Grudges that fester or get let go, and feelings that drift back toward a baseline as days pass Love in steps: attraction, crush,…

Struggling to identify scene relative to root node

Godot Version Godot_v4.7.2 Question Hello! I’m trying to write a global script that will handle transitioning between scenes in my game. My issue currently is that I can’t get the script to identify the scene I want disabled (the “Shop” scene.) I don’t know if it’s syntax I don’t know yet or if I’m missing something. I’ve tried making an onready variable for the scene and referencing it any way I can but it always says the node is “not declared in current scope.” extends Node @onready var shop:…

How to make a node inherit another node's position and rotation with code

Godot Version 4.7.1 Question I’m struggling to find a good way to make my character’s gun switch between different hands, my current implementation works like this but has unwanted side effects: in the code of the weapon: func _physics_process(_delta: float) -> void: if gunposition == 0: global_transform = lefthandgunpos.get_global_transform_interpolated() elif gunposition == 2: global_transform = righthandgunpos.get_global_transform_interpolated() This creates some delay when moving the gun…

There is no support for async functions profiling

Godot Version 4.6 Question My scene loading uses a lot of procedural data generation - and a big scene takes up to 40 seconds! I have no clue why - the built in profiler seems to be useless, I cannot find tickbox combo that tells me anything. I guess that is due profiler works per frame. But for me framerate is not issue, I use await and signals to update the progressbar, and that updates fast enough during the scene load few hundred frames are passed. Is the only way to add in functions start…

Resource based weapon system, circular reference issue

Godot Version 4.7.2 Stable Question I want to define my weapons using Resources which would store the PackedScenes for the pickup and the weapon so my player could instantiate the weapon when equipping it from the inventory, or drop the pickup item into the world. The trouble I ran into is that, if my pickup scene holds a reference to the weapon resource which in turn holds a reference back to the pickup scene I get quite a few errors related to the circular reference. I saw that someone else…

Detecting Mouse Click in Isometric Perspective

Godot Version 4.7.2 Question How do I properly do click-detection on isometric tiles using TileMapLayer? Seeing as the textures are cubes larger than the diamond-down isometric grid, I want the entire texture to be detectable as clicking on that coordinate grid space. var local_mouse := main_layer.to_local(get_global_mouse_position()) var cell := main_layer.local_to_map(local_mouse) if main_layer.get_cell_source_id(cell) != -1: return cell Simple code that returns the coordinate of the clicked…

Need help with my json saving system

I’m using 4.7.2 Question I’m trying to remake fnaf world in godot as a fun way of learning and am having some really annoying issues with saving. basically, I can’t find a good way of resetting the save file and data persists from the existing save file before trying to reset it. currently, I am setting a “clean save file” Dictionary at the complete start of the game to reset the save file, this is just the save_dict without any changes applied to it #this happens in the first scene of the game…

Free 3D lock puzzles for Godot 4: combination padlock, keyed padlock + key, hasp (MIT scripts)

I made a small set of PS1-style lock puzzles that work in Godot 4 out of the box: a 4-wheel combination padlock, a keyed padlock with a key, and a hasp they hang on. Hooking one up looks like this: var lock: CombinationLock = preload("res://psx_locks/combination_lock.tscn").instantiate() lock.name = "CodeLock" lock.code = PackedInt32Array([1, 9, 8, 5]) add_child(lock) var hasp: Hasp = preload("res://psx_locks/hasp.tscn").instantiate() hasp.lock = NodePath("../CodeLock") # set before add_child…

Buttons not working after switching scenes

godot 4.7.2 i have a menu that pops up once the player loses, that can send them to the main menu, retry the game or send them to an upgrade tree, the problem is that once i switch back to those scenes ( for example the main menu scene ), the buttons stop working, they do work normally if i start the game on those scenes tho heres the code for the buttons @warning_ignore("missing_tool") extends Button class_name redirect_button @export var target_scene : PackedScene func _ready() -> void:…

Animation Help needed

Godot Version 4.7 Question I have a attack function that plays a animation if you attack and flips the animation if your facing left cause the animation faces the right but first off it plays the animation but so fast you can barely see it and secondly it doesnt flip. I also get a error ill include it #attack function error: E 0:00:01:599 Player.attack: Invalid operands 'float' and 'String' in operator '=='. <GDScript Source>player.gd:127 @ Player.attack() <Stack Trace> player.gd:127 @ attack()…

Controlling the character by moving the mouse cursor to the screen edges

I got an idea for controlling first person movement by having a freely moving cursor on screen that moves and turns the character when it is close to the screen edges. Could be useful for my game, or it might be terrible. Only way to find out is trying it. What I am unable to find information on is how to register the cursor being close to a screen edge as an input event, so I can have the character perform a movement in response. What do you use for that? 4 posts - 3 participants Read full…

Enemy pathfinding in a proceduraly generated world

Godot Version 4.6.1 Question I am trying to implement pathfinding into my game, but the enemy will not move and i think the problem is not as simple as baking it in the editor due to having procedural terrain generation so i would have to bake at runtime i was using this example here from godot docs: func _ready() -> void: var on_thread: bool = true bake_navigation_mesh(on_thread) And the navigation is from a tutorial here and the code for the enemy is not complex: extends CharacterBody3D var…

My charecter just gets "stuck" to my enemys when i walk into them bottom up. but only from below

Godot Version 4.7 Question so when I walk into my enemys from the bottom side to the top, my charecter just gets stuck to them??? And the only way to be let free is by walking into an object on the map like a rack or tree that has a collision to seperate the enemy and player. I really dont know what could be causeing this. I don’t think it’s somthing to do with the code, but if you want to check any of my code. ask and ill provide it to you as a reply. 4 posts - 2 participants Read full topic

How do I communicate with my Autoload scenes/scripts?

Godot Version 4.7.2.stable Question Hiii, so, I added an audio manager I seen from this video, all I wanna know is how do I go about getting a reference to the Autoloaded scenes there so i can modify things on it(music and volume) (Idk yet if my GameManager should also be on Autoload, next step for me is I need to learn where to store setting variables to make sure they are the same in all scenes still figuring that out ;p) 2 posts - 2 participants Read full topic

Can't mute the server window

Godot Version 4.7.1 Question How do I mute the server window or ideally make it render blank 2d scene instead of using the first 3d camera it can come across? my current attempt at this: if is_multiplayer_authority(): print("test") AudioServer.set_bus_mute(AudioServer.get_bus_index("Master"), true) this triggers when a player joins the game, it prints test into the console but does not mute the audio coming from the server window it’s been getting on my nerves for awhile but is now also making…

Unparenting a Node2D while retaining its position, scale, rotation, skew

Godot Version Godot_v4.7-stable_linux.x86_64 Question So initially, I (naively) have Utility functions for parenting/unparenting: func parent_add_child_without_transform(parent: Node2D, child: Node2D) -> Transform2D: var global_transform = child.global_transform parent.add_child(child) child.global_transform = global_transform return global_transform func parent_remove_child_without_transform(parent: Node2D, child: Node2D) -> Transform2D: var global_transform = child.global_transform…

My tactics enemy AI is one scoring function with 11 weights, so I had a bot play 600 battles to see which ones matter

Last time I posted about Tactics Kit it was about the rules side (events, previews on a cloned board). This one’s about how the enemies decide what to do, because it ended up a lot simpler than I expected. Each enemy just tries everything. On an 8x8 board that’s cheap, so for every cell it can walk to and every way it can aim from there, it scores the attack and keeps the best one: for c in cells: var approach := -APPROACH * _distance_to_squad(c, squad) if fire_lanes.has(c): approach +=…

Animation player foreign problem

Godot Version 4.7 Question so it can be clear form th ebegining i am not wokring on windows i am working on tablet dex mdoe so files work diffrently and the rpoblme is that i moved my animtion player form my 2d game proejct to another 3d game roject and then puted the file back to the 2d project and now i cant edit or move or put any new keys or add keys and when i click animtion then mange animtions i find that writen near every animtion and the root node and eveyrthing sayes foreign near it…

Reading a text file "line by line"

Godot Version 4.6.1 Question This is probably a very simple question, but I couldn’t find anything relevant online. I want to have a dialog system, a VERY basic one however which is completely linear. As such I had the idea to create a .txt file and have each line of dialog be written in one line of the file. IE: “Line one Line two Line three” However I don’t know how to code in something that only reads one line of the text. For example, if I have a variable that counts up when the dialog…

Problem with optimization

im using godot version 4.7.2 stable so i have an upgrade tree, and once i hover over an upgrade with my mouse, it makes a colorrect with a richtextlabel that shows description and effect, but when i hover over it for the first time, it freezes for a lil bit (happens with every upgrade once), heres the code @export var upgrade_description : String func _ready() -> void: pressed.connect(on_click) mouse_entered.connect(on_hover) mouse_exited.connect(on_hover_exit) #this entire section is to…

Error not showing up in the debug window

Godot Version V4.7.2 Question # Quit if the audio bus wasn't found if audio_bus_id == -1: push_error("Could not find target audio bus: " + audio_bus_name) push_error("Quitting...") get_tree().quit(1) For some reason I don’t see any errors in the debug window or console when this runs. Am I not using push_error() correctly? 5 posts - 3 participants Read full topic

Issue with diagonal movement being faster even though all vector lengths are 1

Godot Version 4.7.2 Question Even though I’m using a vector3 that’s normalized moving diagonally either with holding left/right and forward/backward or looking diagonally is causing movement to be faster all normalized vector lengths are 1 and the one non normalized vector’s length is the max speed. Here’s the code(I pasted it instead of a screenshot as there’s a lot of non movement related clutter in the function) var input_dir : Vector2 = Input.get_vector(“move_left”, “move_right”,…

preloading a png into a button icon with path based on arraydata does not work

Godot Version 4.7.2. Question Hi! I am building a trade RPG where you buy and sell items from one NPC to another. For the trade menu’s I am loading in sprites into the icons of a button. This is so its clear what someone is buying. I am having trouble with it however. This is the current way I am doing it: $buyBox/ColorRect/marginContainer/interacteables/tradeables/VBoxContainerTradeables/npcItemBox2/item3R1.icon = preload("res://art/Beans.png") But, because there will be quite some NPC’s in…

Super Checker - Plugint to push warning if there is no super in inherited funcs

Super Checker Godot 4 plugin. Pushes the warning if there is no super called in inherited functions. You can download it from the Godot Asset Store or on GitLab. About I often forget to call super in overridden methods within my derived classes. Especiall overridden built-in virtual methods! Countless times, I have added a new method to a base class, only to find out (usually a day later), that one of derived classes already had it and was now overriding it. And unexpected behavior, that I was…

Vertus: A Virtue & Vice Tale, a old-school text-based adventure game is out now! Pay what you want

Hi everyone, I’m excited to announce the release of my first solo project, Vertus: A Virtue & Vice Tale. Made with Godot 4.6, this game is completely text-based. All the actions and choices you make are typed out by you. In this game, a young teenager named Vertus has been torn from his family and drafted into a war. It’s up to you to help guide his actions and ensure his survival no matter the cost. Some additional Information on this game: Up to 4 hours of content (meant to be finished in one…

Season Tracker for Tycoon Sim, Working but feels bad

Godot Version 4.6.1 Question This script works but it needs feedback, if this is what gets used I won’t be mad about it, it does the job I need. However, I feel it could be better. I’m a beginner though so I can’t think of better This is my season manager/tracker it’s job is to get the worlds current season based off the date. It has a date manager that it steals from the overarching world manager, a seasonal position that is just the date reformatted into mm-dd, and a current season variable.…

How to "lighten/max blend mode" one image object onto another?

Godot Version 4.7.2 Context Hello, I’m trying to add and remove data from an image like a digital brush would. The intention is to use the output image data as the base for my smoothly interpolated marching squares algorithm. I have already managed to hook them up, and I am very pleased with the result: For the interested, this is the script (beware that it uses data from an image instead of a dictionary) (click for more details) Where the question comes in The problem with my method blending a…