How to use tool and setget to monitor changes to a curve?

Ryan ScottRyan Scott Posts: 24Member

I have a scene that contains a Path2D and some nodes that follow it. When the path curve changes at all I want it to update in the editor, but I cannot figure out how to detect the changes to the curve to do the update.

Below doesn't work, setget isn't run. Any idea how to detect any change to the curve?

Answers

  • TwistedTwiglegTwistedTwigleg Posts: 4,771Admin

    Unfortunately, I think I remember reading somewhere that you cannot use setget on built-in Godot node properties in GDScript. I can’t find where I read it though, so maybe it’s not an issue anymore?

    This Godot QA question has an answer mentioning you can override the _set function to detect changes, but apparently it only works if the property is changed by calling set and changes directly to the property do not, so I’m not sure how usable it would be in this case.

  • RattyRatty Posts: 20Member

    I have a similar problem, the following added to a 2D sprite should print to the output any property that is changed on the sprite:

    tool
    extends Sprite
    
    func _set(property : String, value):
        print(property, " ", value)
    

    It works if I change a property in the property inspector but not if I change something, scale for instance, by using the mouse in the visual editor.
    I do not think there is a way round this, unless anyone has any suggestions?

  • Ryan ScottRyan Scott Posts: 24Member

    I've learned that not all values are tracked and so would need to be added to the engine

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file