I built a simple scene that I instanciate at will. Simply a
KinematicBody2D as root, containing a
Sprite and a
CollisionShape2D. There is a script linked to the root node that basically expose a few properties to describe an orbit and make it move in orbit around its parent. The point being to make a very basic solar system simulation or anything that requires a node to move around another in a circular fashion.
The movement work fine and I’ve been playing around my scene tree, instancing a bunch and watching them move around as moons of planets, etc. But the texture is all the same. If I make children editable, I can go change the texture of the sprite, but I’d like to expose that property from the root node so I can access it directly from the editor.
I tried adding an exposed property with a setter and a getter to assign and retrieve the texture, but it seems to crash Godot completely with this code:
export(Texture) onready var texture setget texture_set, texture_get func texture_set(newtexture): $"Sprite".texture = newtexture func texture_get(): return $"Sprite".texture
Is there a solution for that? Or simply another way?