Hello!
What is the problem exactly? E.g. the enemy is moving but not collide with the player?
Have you try this?
var playerobj=move_and_collide(dir * speed * delta)
if (playerobj):
if playerobj.get_collider()==“Player”:
gettree().change_scene(“res://TitleScreen/TitleScreen.tscn”)
func _physics_process(delta):
var obj = getparent().getnode("Player")
if obj:
var dir = (obj.globalposition - globalposition).normalized()
moveandcollide(dir * speed * delta)
If that works it’s because your Player node wasn’t _ready() at the time that object was _ready().
“When instantiating a scene connected to the first executed scene, Godot will instantiate nodes down the tree (making _init calls) and build the tree going downwards from the root. This causes _enter_tree calls to cascade down the tree. Once the tree is complete, leaf nodes call _ready. A node will call this method once all child nodes have finished calling theirs. This then causes a reverse cascade going up back to the tree’s root.”