godotengine / godotengine/godot-docs

Mention behaviour / limitation of instance_id (regarding saving games)

Open
#8,869 1 comment 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:**
4.2.1

**Issue description:**
1. If I understand correctly the IDs returned by [get_instance_id](https://docs.godotengine.org/en/stable/classes/class_object.html#class-object-method-get-instance-id) are [generated at runtime](https://forum.godotengine.org/t/should-i-use-get-instance-id-to-save-game/23402).
2. However this is not mentioned in the docs (or I didn't find it)
3. That means it's _not_ suitable to be used for referring to an object in a save system
4. The [tutorial on saving games](https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html) should mention this IMO and give a hint on what a solution to this problem would be

**Note:** I'd be happy to write that paragraph ... but right now I have no clue on what a good system would be (that doesn't require giving thousands of objects manually an ID). I at least found [this article](https://www.gamedeveloper.com/programming/building-a-simple-system-for-persistence-with-unity) on "persistence" but I am not sure that system is applyable in Godot.

**URL to the documentation page (if already existing):**
- https://docs.godotengine.org/en/stable/tutorials/io/saving_games.html
- https://docs.godotengine.org/en/stable/classes/class_object.html#class-object-method-get-instance-id

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.