Help: Godot overrides instance`s references

Godot version: 4.2.0.0 mono (.Net) win64
Renderer: Forward+

Excuse me for my bad English as I`m not a native speaker.

In my project Godot always overrides exported properties of instances. Sometimes it cause bugs (For example, two enemies reference on navigation agent of one of them (each one has to reference it`s own agent). As a result they travel the map incorrect.

I want you to tell me how to fix this or to explain how to work with references and instances propely.

Steps to reproduce:

  1. Create a C#/GDSkript skript and add an export variable:

    • C#: [Export] NavigationAgent3D navAgent;
    • GDSkript: @export var navAgent: NavigationAgent3D
  2. Save the skript (Build project if you use C#) and create a new scene with root Node3D.

  3. Instantiate NavigationAgent3D node as a child of root node.

  4. Add your skript to Node3D and add reference on NavigationAgent3D in the inspector of Node3D.

  5. Save the scene.

  6. Create new scene with root Node3D and add an instance of previous scene to this scene

  7. You get this image:
    изображение
    This works for C# too.

As you can see, the value of NavAgent has been overriden. If you will click on ‘revert’ button, button will disappear, but value of property won`t change.

What have I do to deal with this problem?

It sounds like this could be related to this issue: Duplicating a node with an export variable doesn't update variable's nodepath · Issue #82670 · godotengine/godot · GitHub that hopefully should have been resolved in 4.2.1. Might have been an over-simplification, but like you write node paths (references to other nodes in exported variables) always seems (or seemed) to be interpreted av overridden when importing a scene. This made no difference when instancing single scenes, but it had the consequence that when duplicating an instance the references would still reference the original instance nodes.

But hopefully this should now have been fixed in 4.2.1. And if it hasn’t, you can just remove the override manually on the paths before duplication, or making new instances from file instead of duplicating instances in the scene to get around this.

Thank you for your reply. This issue is still present in 4.2.1. But your idea of getting rid of overiding before duplicating helped me a lot. Thanks)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.