The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

guys i have a node with a variable = 0 and its instance is made unique (any changes dont affect other instances) with the variable =1 and i called it from another script using the variable but instead of using the unique instance variable(=1) it uses the main node variable (=0) so how do i make it use the unique variable (=1)

Godot version 3.5.1
in Engine by (27 points)

1 Answer

0 votes

Maybe You are mixing thing up
When You save a node as a .tscn file it is a shared blueprint for your instances. All nodes created from this scene using instance()become unique, but start with the base variable You introduced in the blueprint. If You want instances to have unique values, You have to set them by code or introduce variables as export and save instances as another scene.

Or do You mean You try to set value by code, but it gets back to 0 ?
If so, then make sure, if your variable is not set to 0 AFTER You set it to 1 ;)
for example if You set it to 1 in init(), but class scene changes sets it to 0 in ready()

by (8,188 points)

I am gonna add more details to the question so i have a door that when i touch i go to next level and to know which level i am in i added a variable calle (current level) and i exported it and in each level i modify its value to the level number and in code i made it so if the player touches the door it changes scene to (current level)+1 it works fine but now i want to save the players progress so in the save function it saves the (current level) value into a cfg file and it worked but instead of saving the exported value that i modify it saves the original value which in code is 0

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.