Reputation: 21452
I need Instantiate Characters in path moving from the start of path to the end of it.
My tries:
public class EnimaySpwan : MonoBehaviour
{
public GameObject gameObject;
public Transform WaterSpawn; // this where I want my enemy appear
private void Update()
{
Instantiate (gameObject, WaterSpawn.position, WaterSpawn.rotation);
}
}
My object movement script:
public class Mover : MonoBehaviour
{
public float speed;
private void Start()
{
GetComponent<Rigidbody>().velocity = transform.forward * speed;
}
}
This code makes character move in direct way, not in the specific path I draw as I want.
I need to create path for my enemies from start of a path (Instantiation) position to end of path (destination).
How can I approach this, any help?
Upvotes: 3
Views: 18060
Reputation: 111
If I understand correctly - you want to spawn an enemy in point A and make it move to point D through points B and C (or any other kind of path). Try placing empty objects on your terrain then:
transform.position
of points B and C in your path.Or you could use a NavMesh
. Here is a tutorial explaining how to implement a Nav Mesh Agent: https://unity3d.com/learn/tutorials/modules/beginner/navigation/navmesh-agent
Upvotes: 3
Reputation: 679
Using iTween editor is the easiest way to do this without much programming skill. https://www.assetstore.unity3d.com/en/#!/content/84
Upvotes: 2