-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Replacing a scene using a custom _replace_scene function causes a crash or unexpected behavior when the old scene and new scene share the same resources as the nodes reference old initialized nodes.
The built-in change_scene_to_file seems to work completely fine.
My problem case:
The below code crashes saying player is null. When I print player in ready it references player node from old scene
extends Node3D
var player: Node3D = null
var player_head: Node3D = null
func _ready() -> void:
var players = get_tree().get_nodes_in_group("Player")
if players.size() > 0:
player = players[0]
player_head = player.get_node("Body/Neck/Head/Eyesight")
func _process(delta: float) -> void:
global_position = player_head.global_position
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels