Godot Version
Godot 4.2.1
Question
when exporting my game to HTML5 it runs completely fine until an explosion effect is spawned on screen for the first time when killing a mob, the game freezes for an entire 2-3 seconds, an easy fix is to just spawn it at the startup of the game so that the freeze would happen at the start instead
func _ready():
var SMOKE_SCENE = preload("res://smoke_explosion/smoke_explosion.tscn").instantiate()
get_parent().add_child(SMOKE_SCENE)
SMOKE_SCENE.position = Vector2(0.0, 0.0)
print("spawned smoke")
but for some reason this isn’t working and the smoke isn’t being spawned at the start
func _ready():
var SMOKE_SCENE = preload("res://smoke_explosion/smoke_explosion.tscn")
var smoke = SMOKE_SCENE.instantiate()
get_parent().add_child(smoke)
smoke.position = Vector2(0.0, 0.0)
print("spawned smoke")
this also didn’t work, the smoke isn’t being spawned at the start
get_tree().add_child(smoke)
tried getting the tree instead of the parent but it doesn’t help
I tried putting breakpoints in the _ready function to see if the smoke is actually being instantiated at the start and I noticed that it seems to be instantiated and put in the game before any of game graphics actually appear on screen, so it looks like it’s appearing and disappearing before we even see it, so it fixes nothing !
Any help is appreciated !!!