Skip to main content

Smooth Preload in Godot

·1 min

When you are using particle in your game in Godot 3.2, there will be a noticable freeze when the first time the particle run. This annoy me and I try to search online for the solution. I stumble upon this link and there is a work around by girng. Below is the code for the workaround:

extends CanvasLayer

var smooth_preloads = []
func _ready():
	smooth_preloads.push_back("res://Scenes/ItemTemplate.tscn")
	smooth_preload()

func smooth_preload():
	for path in smooth_preloads:
		var t = load(path).instance()
		add_child(t)
		yield(get_tree(), "idle_frame")

I’ve tested the code and it is running smoothly without freeze.

Henry Thomas
Author
Henry Thomas
Just a guy with a pen and a dream