godotengine / godotengine/godot
Scene instances with exported array would access same array ONLY if array was modified in editor beforehand
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproduced in 4.0 stable, 4.3 Stable and 4.4 dev1
### System information
Godot v4.3.stable (77dcf97d8) - Freedesktop SDK 23.08 (Flatpak runtime) - X11 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3070 Ti (nvidia) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)
### Issue description
When instance a scene multiple time, and the instanced scene has an exported array,
Modify said array in the scene would cause the every instance of the scene share the same array;
It doesn't happen if the exported array was never modified, or was modified again after instanced in editor.
Edit: Just realized I wasn't clear enough, I'm talking about modified IN INSPECTOR, the part it shows export var.
### Steps to reproduce
1. Make a scene with exported array.
2. Append something into the array, then print it.
3. Instance the scene multiple time into another scene, then run the big scene, check if it prints the same thing for every instances.
4. If so, go back to the scene, add an element to the array in inspector.
5. Run the big scene again, the array now gets bigger as every instance append element into the same array.
6. Further more, modify array on one of the instance in the big scene, will make it isolated and not having the problem.
### Minimal reproduction project (MRP)
[ExportedArrayAppendBug.zip](https://github.com/user-attachments/files/16767838/ExportedArrayAppendBug.zip)
Contributor guide
Research direction
Start by downloading ExportedArrayAppendBug.zip and reproducing the behavior in Godot 4.0, 4.3, or 4.4 using the listed steps. Compare exported-array behavior between the instanced scenes before and after editing the array in the inspector. Done means repeated scene instances no longer unexpectedly share the modified array.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- godot
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100