Hi there i am working on a project. i want to make my enemy/mashroom move to the player and a lot of them and i got that but the move ment is the problem when i load the scene it will move but it goes to the places i spawn at, and i also want to add in that i have it so a gui loads my character into the game because i have more then one playable character. pls help me here is my mashroom code it is in GS.
extends Node2D
@export var enemy_scene: PackedScene = preload(“res://Scenes/Mashroom.tscn”)
func _ready():
var character_name = Global.selected_character # “Knight”, “Mage”, or “Rogue”
var player_scene_path = “res://Scenes/%s.tscn” % character_name
var player_scene = load(player_scene_path)
var player_instance = player_scene.instantiate()
player_instance.position = Vector2(100, 100)
add_child(player_instance)
# IMPORTANT: Add player instance to "player" group so enemies can find it
player_instance.add_to_group("player")
# Spawn enemy after player exists
await get_tree().process_frame
spawn_enemy()
func spawn_enemy():
var enemy_instance = enemy_scene.instantiate()
# Spawn enemy offscreen or at a fixed position for testing
enemy_instance.position = Vector2(400, 100)
add_child(enemy_instance)
let me know if you need to see anyother code to help