0 votes

The problem is quite simple: I make the classic scheme of adding a scene with instance and everything normal, except that the first time the new scene appears, the game freezes a lil. And it's only the first time the scene is instanced.

Imagine this: I make a instanced scene that is a shot and this shot will appear several times in the game, even if it disappears from the screen after a while (with "queue_free"), only first time it appears is that the freeze problem occurs.

How can I solve it?

Tks guys

asked Oct 11, 2019 in Engine by lucasfazzi (156 points)

1 Answer

+1 vote
Best answer

Just had the same problem, and fixed it by using preload function:

var my_scene= preload("res://scenes/MyScene.tscn")

If you use "load" function just replace it with "preload". Load is lazy fetching, it fetches the resource when it appears. Preload is eager - it does it at the start.

answered Oct 11, 2019 by gmaps (692 points)
selected Oct 11, 2019 by lucasfazzi

solved; you are my hero

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 How to use this Q&A? before posting your first questions.