Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice
  4. Join us on Thursday, September 29, for a day with Unity's SRP teams here on the forum or on Reddit, and discuss topics around URP, HDRP, and the Scriptable Render Pipeline in general.
    Dismiss Notice

Spawning AI with a winding changing path

Discussion in 'Scripting' started by SoldierofYHVH, Aug 12, 2017.

  1. SoldierofYHVH

    SoldierofYHVH

    Joined:
    May 31, 2017
    Posts:
    8
    After making a transition from AS3 to C#, and thousands of hours studying C#, I began production on my 3D , top down shoot em up car chase concept. I've been working in 3D for ten years now, so that isn't going to be a problem. As I'm finding out, creating and animating 3D for videos and film is a bit different than creating for games After getting a firm understanding of pooling in my grasp, it seemed like I could pool my AI cars, spawn them just ahead of the camera, destroy them a few feet behind the camera like I'm doing with other objects. However, the road has curves, twist and turns, so a predefined way point system prefab would seem to cause problems when spawned and pooled (if that set up will work). I've been studying up on game design, but I'm still not certain how to go about setting up the AI cars on the highway (that are not involved in the pursuits). How can I spawn cars to conform to a road that has random twist and turns? The player car drives without AI and the pursuing vehicles, up to this point, are just following the player while avoiding obstacles.

    In 3D Max and Cararra, when I create a chase scene, I simply populate the highway with the civilian cars that will be involved in the scene (I use paths and other methods to achieve this). This particular level of the game consist of police cars and helicopter chases, thug enemies in cars and cycles, as well as the typical civilian motorist that you have to keep mindful of. I already have the chases set up and they are following the player car while avoiding obstacles on the highway. The pursuing vehicles do not have way point AI, but they are able to detect other vehicles and assets and avoid them. In the case of the police vehicles, once the player exceeds a certain speed, they back off. The police vehicles are set up to be spawned behind the camera when the player passes specific triggers. I have similar triggers for the thug enemies which are spawned according to a timer. I'm still tweaking this system, but it is working well up to this point. It's the civilian motorist that are throwing me for the loop. I'm not quite certain how to spawn those vehicles AND their way points with the highway taking various turns (it is not a repeating piece of track). The civilian cars AI and way point systems are all set up. I'm just stumped at how to get those cars and their way point prefabs to to align on a highway that has turns and twist. Sorry for the novel, but I'm trying to be clear in what I'm trying to achieve.

    What would be the most practical and efficient way to set up the AI for the civilian cars? I apologize in advance if I've posted this question in the wrong area. I'm not used to using forums and I'm new to the Unity forum. Pseudo-code, concise explanations, or pointing me in the right direction is all I need.

    Thanks!
     
    Last edited: Aug 12, 2017
unityunity