Unity - Draw Path for Characters to follow

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Unity - Draw Path for Characters to follow



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?





Can you add more details please? What exactly is wrong? What errors are you getting?
– MKII
Aug 25 '15 at 15:12




2 Answers
2



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:
1. spawn enemy
2. get transform.position of points B and C in your path.
3. keep updating transform.position of the enemy till it gets to B then to C and finally to D. etc



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





Please don't add "naked" links, but give a short explanation of what the link is about.
– MKII
Aug 26 '15 at 6:55



Using iTween editor is the easiest way to do this without much programming skill. https://www.assetstore.unity3d.com/en/#!/content/84






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS