Hi,
I wrote class Bouncing which export some variables. I add this class to one node, and also export it, creating new instance in same line. When i create int variable, it’s possible to change it in editor as intedned, but in “Bouncing” section, there is only possible to assign new value.
Node which use and export Bouncing class part
@export var testInt: int = 12
@export var bouncing: Bouncing = Bouncing.new()
Boucing class part
@export var bouncing_object: Node3D
@export var bouncing_speed = 5.0
@export var bouncing_height = 0.5;
And the result is…
I wan’t for example change bouncing_speed from this place.
I’d rather instantiate the bouncing using the instantiate method (with a PackedScene being a template/empty Bouncing node) rather than the new constructor, maybe that could explain why Godot doesn’t truly instantiate your Bouncing node, since your class does not have a static method called ‘new’ overriding the constructor
This is not a Node, RefCounted or Resource. It’s just a plain class, which i use as “trait”, so add necessary code to user node to bounce. Should I avoid that approach. Should i always use one of Node/RefCounted/Resource?
Don’t use Nodes for a new’d @export, sounds like it’s getting deleted or lost because it’s not added to a scene tree. For reference @export nodes are saved as node paths, so it can’t store unpathable Nodes.
If it has to be a Node then you have to add it to the scene, otherwise switch to a Resource for it to be editable in inspector.