Godot Version
4.2.1
Question
Hello. I have added a very simple boss fight to my game, a boss that is using a finite statemachine it only has 1 state currently and that is the ‘chase’ state that is supposed to chase the player when the boss fight is triggered, when I load the scene that contains the boss fight it works how it should, however when I load a different scene and I move into the scene with the boss fight the boss can’t find the player node in the scene tree for some odd reason. I can’t figure out what I need to do in order solve this problem.
This clip shows exactly, what I mean.
Boss chase state code
extends State
class_name BossChase
@export var boss: CharacterBody2D
@export var movementSpeed : float = 15
var target = null
func _ready():
target = get_tree().get_first_node_in_group("Player")
func physics_update(delta : float):
if is_instance_valid(target):
var direction = target.position - boss.position
boss.velocity = direction.normalized() * movementSpeed
What the boss scene tree looks like