0 votes

Hi all.
I have a multimeshinstance3d node in my scene and I want to see the properties update in real time in the editor when, e.g., I change the instance count in the inspector.

In my code, I loop through the instances and apply transforms to each based on a 'center' node, which is just a node3d. Multimesh Instance transforms are set to spawn around this center 3d node. Again, I want to see the instances 'follow' the center node as I move it in the editor.

I'm using the @tool keyword at the top. The logic for the multimeshinstance3d is all kept in one function (which does the looping, sets transforms etc). If I put that function in process, it will update real time in editor but it will be very expensive (especially with thousands of multimeshes). What I want to do is somehow detect when the center node is moved in the editor as well as when an export property is changed in the inspector, and only run the function then. How do I do that? I've experimented with the property-list_changed signal, but to no avail...

Godot version 4.0
in Engine by (506 points)
edited by

1 Answer

0 votes

In Godot3 you'd do that with setget but in Godot 4 you could do something like that instead:


@export var center: Vector3:
        return center
        if value != center:
            center = value

I don't know if the syntax is exact, I dont have the engine to verify, have a look here: https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/gdscript_basics.html#properties

Another way to go without properties is to remember the previous value of center and detect the change inside _process.

by (29,042 points)

Thanks. I was baffled to see setget gone in 4. I managed to find the relevant docs and got it to work in the interim, although the tip about checking prev property status in process is a good one, why didn't I think of that...

Anyway, we're all waiting for you terrain plugin to be updated to Godot 4. Jut saying:)

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.