Hi i am new to Unity and i have a problem. I try to make a wavespawner that spawns enemies from a prefab. Those enemy prefabs should spawn and start follow the player. Its a 2D game and i am using Aron Granberg's Astar Pathfinder. I easily set up all scripts for my enemy prefab.. but the only problem with the Destination script i can't solve is: How do i get the Transform from the Player into that prefab. If you know the answer please keep it simple thanks!
I'm having the same issue...did you ever find a solution? I think the best way to fix it, is to add a start function that makes the enemy target the player at when it spawns, but I'm not sure how to do that since I'm a beginner to reading/writing code.
Uhh.. I'm beginner as well. But there is this code : Vector3.MoveTowards. This code can be used to follow a player. Link : https://docs.unity3d.com/ScriptReference/Vector3.MoveTowards.html Note: target is Player GameObject Code (CSharp): public float speed = 20; public GameObject target; void Update(){ ChaseTarget(target); } void ChaseTarget(GameObject target) { // Move our position a step closer to the target. float step = speed * Time.deltaTime; // calculate distance to move transform.position = Vector3.MoveTowards(transform.position, target.transform.position, step); } Not sure this is what you looking for. Hope this helps you.