godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.99k stars 20.18k forks source link

"Found invalid node path" error when renaming node to match nodepath field default value #60387

Open Flavelius opened 2 years ago

Flavelius commented 2 years ago

Godot version

3.4.4.stable.mono.official

System information

Windows 10

Issue description

https://user-images.githubusercontent.com/8841352/164180992-7ea27a8f-b6f9-4868-b1c9-aece46e04076.mp4

See this attached video. The default nodepath value of the script is 'ExitPoint'. When a child node with a different name is renamed to match this name, an error is printed to the console 'Found invalid node path [...]'.

P.S. With this case it occurred to me, that even though the automatic nodepath refactoring is nice and helpful, it also seems like a way to unknowingly mess up setups, because once the internal mechanism catches a renamed node (node path matches) it locks onto the caught node and adjusts to its name changes, even though that may have happened accidentally (temporary rename). Maybe there should be a message instead of this error that notifies of such an implicit capture.

Steps to reproduce

Have a script export a nodepath with a default value, create a node and assign it that script. Add a child with a random name. Change that name to match the exported nodepath value and see the error printed in the console.

Minimal reproduction project

No response

Calinou commented 2 years ago

@Flavelius Please upload a minimal reproduction project to make this easier to troubleshoot (one using only GDScript, not C#).

Flavelius commented 2 years ago

MRP.zip It's probably faster to simply recreate it in some other project than to download, extract and open this example, but okay, here it is. It's really just a single exported nodepath on a node in a scene with a child node. Rename the 'Child' to 'NamedNode' to see the effect.

ajreckof commented 1 year ago

This is still happening in 4.0.2 but it's low priority as the only bug is that it shows an error where there should be none.

Tuckertcs commented 11 months ago

Adding that this isn't just about renaming nodes, as I get this when deleting nodes sometimes as well.

Oddly enough, it happens in a very specific case:

I have a BattleScene node with a PackedScene reference to a Pawn node. Both nodes are tool scripts, so their visuals can update within the editor.

When I delete a node from BattleScene, I get "Found invalid node path 'Collider' on node 'BattleScene'". The collider it mentions is inside the Pawn node (with a exported variable to reference it). Now the weird thing is that the Pawn isn't in the BattleScene, it's only inside the PackedScene export variable. If I set that variable to null, I don't get this error message anymore.