Godot Version
4.6.1
Question
Im trying to do one of those desktop pets to get familliar with Godot. I did some research and assigned Polygon2D to AnimatedSprite2D, turned on project settings (“transparency”, “borderless”, “pixel transparency,” “fullscreen”, “always on top“ and “transparent background”) and wrote this in my code:
func _ready() -> void:
get_window().mouse_passthrough = false
get_window().mouse_passthrough_polygon = $"Polygon2D".polygon
Upon running my project, window is fully transparent and i can click through it, but it also causes my sprite to completely disappear. I tried different solutions from youtube and this forum, but none of them worked for me.
Heres some solutions that i tried:
var updated_polygon_array: PackedVector2Array = PackedVector2Array()
for point: Vector2 in $"Polygon2D".polygon:
updated_polygon_array.append(point * 3 + animated_sprite.global_position)
print(updated_polygon_array)
get_window().mouse_passthrough_polygon = updated_polygon_array
#Tried to put this code in _process() and ready() functions, both didn't work
func _process_clickables() -> void:
var clickable_nodes = get_tree().get_nodes_in_group("Clickables")
for node in clickable_nodes:
if node in Control:
var rect = node.get_rect() as Rect2
var texture_corners: PackedVector2Array = [
rect.position, #top left corner
rect.position + Vector2(rect.size.x, 0), #top right corner
rect.position + rect.size, #bottom right corner
rect.position + Vector2(0, rect.size.y) #bottom left corner
]
DisplayServer.window_set_mouse_passthrough(texture_corners)
else:
printerr(node.name + " is not control")
#function is called in _process()
I would appreciate the help.