- Home /
how to generate infinite nav mesh path
Im trying to make an endless runner game like in subway surfers/ highway pursuit games.
A clone copy of the level that ive created is always being constantly generated which is what i want since i want the player to be always moving forward but i cant get the nav mesh path to do this as well. I have an enemy thats always chasing the player using this nav mesh path but i cant get this nav mesh path to automatically be generated also as the world in the level is generated.
Does anyone know of a way that i can do this it would be really helpful or even provide a code sample of this? The code below is the one i used to generate the level i created in my world
public class roadTrigger : MonoBehaviour {
public Transform roadPrefab;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
private void OnTriggerEnter(Collider other)
{
Instantiate(roadPrefab, new Vector3(0, 0, transform.parent.position.z+49f), roadPrefab.rotation);
transform.parent.gameObject.AddComponent<timetodestroy>();
}
}
Answer by Cuttlas-U · Oct 25, 2017 at 06:35 AM
hi; usually in runner games what we have to do is seperating parts of the worlds and saving them as prefabs;
to move the player as i saw before we cant use navigation but we should use waypoint system;
we created some points inside each part of the worlds and when player reach the end of points in 1 world it get the first point in the next world and try to move to it;
as this has been done in subway surfe ;
I did separate parts of the world and save them as prefabs. I made that world and created a copy of it so that the copy would work as a clone
would i need to create a script for the waypoint system or does this come with unity?
how would i implement waypoints for the enemy to always follow the user/player in whichever direction they go? Both the user and the enemy travels in one direction which is forward but the user is also able to go both left and right and the enemy should follow that as well based on what the user does
hi again; well as it is called its a "system" so i cant give u the code i just can show u some toturials but u have to write it on your own cause its your game;
if u like i can give u some tutorials i think or explain how to make it ? but i dont have to write the code sadly; i saw your massage in gmail by the way;
Answer by x4637x · Oct 26, 2017 at 10:30 AM
I think you will find this useful : NavMesh building components
Your answer
Follow this Question
Related Questions
Getting a navmeshagent back on a navmesh. 1 Answer
How do I get agents to avoid each other? 0 Answers
Navmesh y-axis 1 Answer
How to use Unity's pathfinding system without NavMeshAgent controlling my character? 1 Answer
How to prevent NavMeshAgents from colliding when warped to same position? 0 Answers