Godot Version
4
Question
Hello everyone,
I’m working on a 2D incremental game in Godot 4, and I’m facing an issue where my spawned objects are functionally present (I can click on them and they work) but they’re completely invisible. The objects spawn correctly, I can interact with them, but I cannot see their sprites.
Here’s my setup:
Game Structure:
Main scene with GameManager, Cursor, Slime, and UI nodes
ClickableObject scene that gets instantiated by GameManager
The Problem:
Objects spawn at correct positions (confirmed via print statements)
Click detection works fine - I get mass when clicking where objects should be
No sprite visibility, even with fallback textures
No errors in console related to sprites or textures
What I’ve Tried:
Ensured Sprite2D nodes exist in ClickableObject scene
Added fallback colored circles when textures don’t load
Verified z-index settings
Checked global_position vs position
Confirmed textures exist in the correct paths
Relevant Code Snippets:
GameManager spawn function:
func spawn_object():
if object_scene == null:
return
var new_object = object_scene.instantiate()
get_parent().add_child(new_object)
new_object.add_to_group("clickable_objects")
var object_type = get_object_type_for_stage(current_stage)
var mass_value = get_mass_value_for_type(object_type)
mass_value *= object_value_multiplier
var viewport = get_viewport()
var screen_size = viewport.get_visible_rect().size
var margin = 50
var pos_x = randf_range(margin, screen_size.x - margin)
var pos_y = randf_range(margin, screen_size.y - margin)
new_object.position = Vector2(pos_x, pos_y)
if new_object.has_method("setup"):
new_object.setup(object_type, mass_value)
print("Spawned ", object_type, " at: ", new_object.position)
ClickableObject setup:
func setup(type: String, value: float):
object_type = type
mass_value = value
var sprite = $Sprite2D
if sprite == null:
print("ERROR: No Sprite2D node found!")
return
# Try to load texture
if sprite_paths.has(type):
var texture_path = sprite_paths[type]
var texture = load(texture_path)
if texture:
sprite.texture = texture
sprite.modulate = Color.WHITE
else:
use_fallback_color(sprite, type)
else:
use_fallback_color(sprite, type)
The objects ARE there (clickable), but completely invisible. What could be causing sprites to not render in a 2D Godot project?
and there another one problem
Cursor sprite doesn’t follow the mouse - I have a cursor Area2D with a circle sprite that should follow mouse movement
Objects don’t break within cursor circle radius - Objects should be destroyed when they’re within the cursor’s radius circle
Here’s my current cursor implementation:
Cursor.gd:
gdscript
extends Area2D
@onready var collision_shape = $CollisionShape2D
var circle_sprite
func _ready():
# Create visual circle for radius
circle_sprite = Sprite2D.new()
var circle_texture = load(“res://assets/sprites/Cursor.png”)
if circle_texture:
circle_sprite.texture = circle_texture
else:
# Create simple circle programmatically
var image = Image.create(64, 64, false, Image.FORMAT_RGBA8)
image.fill(Color(1, 1, 1, 0.3))
circle_sprite.texture = ImageTexture.create_from_image(image)
circle_sprite.modulate = Color(1, 1, 1, 0.3)
add_child(circle_sprite)
update_circle_radius(100.0)
func update_circle_radius(radius: float):
if collision_shape and collision_shape.shape is CircleShape2D:
collision_shape.shape.radius = radius
if circle_sprite:
circle_sprite.scale = Vector2(radius / 32.0, radius / 32.0)
GameManager.gd (relevant parts):
gdscript
func try_auto_click():
if auto_click_damage > 0:
var objects = get_tree().get_nodes_in_group(“clickable_objects”)
for obj in objects:
if cursor and obj.global_position.distance_to(cursor.global_position) <= cursor_radius:
on_object_damaged(obj, auto_click_damage)
func on_object_hovered(object, base_damage: float):
var damage = base_damage * mass_multiplier * click_multiplier
var is_critical = randf() < critical_chance
if is_critical:
damage *= critical_multiplier
spawn_critical_text(object.position, damage)
on_object_damaged(object, damage)
The issues:
The cursor Area2D doesn’t follow mouse movement
Objects don’t get destroyed when within the cursor radius
The circle sprite shows the radius but doesn’t move with the cursor
What I’ve tried:
Using get_global_mouse_position() but not sure where to implement it
Verified collision shapes and groups are set up correctly
Checked that objects are in the “clickable_objects” group
Any help would be greatly appreciated!



