+4 votes

I want to instance a scene and show it before each level in my game. So I use the instance method like -

var MyScene = load("res://Scenes/MyScene.tscn")
var myScene = MyScene.instance()

Now this works, but there is a problem. If I run any script on this scene to say modify size of text, this modification persists when I create another instance of this scene.

Even though when the second instance is being made, the first instance is freed, the second instance contains modification made on first instance (through script).

I want to have unique instances of the scene, which do not share modifications.

in Engine by (16 points)
edited by

Size of which text?
That Scene will contain other Ressources which may be shared between instances. You might need to make the specific ressource which you are altering unique.

@wombatstampede: I have made the resources unique already. That's not the problem. I'd like to change the size of same text in different instances of the scene. But looks like that is not possible right now in godot.

Maybe it is best when you share the part of code where you change the font size.

Do you create a new Instance of DynamicFont or BitmapFont and then use addfontoverride() of the label?

1 Answer

0 votes

Resources migth be shared between instances of a scene i think. So you should try to create a new resource or make the resource "local to scene".

But for the text this should not be the case.....

by (14 points)
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.