Game freeze when i spawn enemies...
Asked Answered
O

2

0

So i instantiate some enemies with NAV, problem is game always frezze a few secs when they spawned. I thought NAV cause this but not.
I find out it from spawn codes, here is codes with freeze:

_zb = zombie.instantiate()
get_node("Chars_List").add_child(
zb)
_zb.global_position = get_node("Spawn_Point_List/Spawn_Enemy2").global_position

Change to this make it no longer freeze:

_zb = _zombie.instantiate()
zb.global_position = get_node("Spawn_Point_List/Spawn_Enemy2").global_position
get_node("Chars_List").add_child(
zb)

Can anyone know why or how it work?


Octal answered 16/3 at 16:21 Comment(0)
S
0

In the code above is zombie using the load() or preload() function?

Solicitous answered 16/3 at 20:54 Comment(0)
O
0

Solicitous
No, i dont load it, i just use:
@export var _zombie: PackedScene
Because I can spawn another types of enemies with this way

Octal answered 16/3 at 22:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.