Getting huge lagspikes when adding a preloaded scene?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ErikDz

So I’ve got this “score popup” which is basically a label with an animation displaying what score the player got when killing a certain enemy. E.g: “+100” or “+300”. Problem is that, whenever I add this scene as a child, a lag spike occurs. Why is that??

Code:

extends Node

func _ready():
	$AnimationPlayer.play("up")

func set_label(text):
	$Label.text = str(text)

Nodes:

You can use the profiler to find out which function is causing the lag spike, I doubt the functions you’ve posted are causing it.

Magso | 2020-08-23 16:19