+1 vote

I have an object (set to tool mode) with some variables that I want to depend on where it's positioned in the scene editor. These variables don't depend on where the object is positioned in general - especially when I animate the object's position during gameplay. Just when the object is dragged around in the scene editor.

I tried overriding _notification and checking for NOTIFICATION_TRANSFORM_CHANGED, but this seems to happen for whenever anything changes the object's position, whether it's the editor or anything else. Using get_tree().is_editor_hint() seems to give a nil error inside _notification.

in Engine by (291 points)

get_tree is only usable after _ready, so it might not be available during NOTIFICATION_READY. Maybe you should check for is_editor_hint only after you are sure it is NOTIFICATION_TRANSFORM_CHANGED? Also, try doing get_tree() != null too.

1 Answer

0 votes
Best answer

The answer is CanvasItem.edit_set_state. Overriding edit_set_state lets me update the variables that depend on the node's position when it's moved in the editor.

by (291 points)

edit_set_state doesn't seem to exist in the current docs. Has anyone figured out the solution for the current version (3.5) of Godot?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.