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. Dismiss Notice

Simple car AI

Discussion in 'Editor & General Support' started by Enumnite, Feb 17, 2015.

  1. Enumnite

    Enumnite

    Joined:
    Oct 2, 2014
    Posts:
    4
    Hello all,

    I'm trying to make a simple car AI script that'll follow a road ( could be direct, curved, zigzagging.. ) turn etc.. and will behave like a normal citizen.

    I tried the script from the Unity sample assets, the AI waypoint system, but I tweaked the option a lot, but that script is more made for an agressive follower ( like cops for example ) than a calm one. The navmesh is logically excluded for performances purposes.

    So I'm trying to imagine a system that'll control the car ( going forward, backward, braking etc ) and follow the road, and apart some low-brow ideas I can't imagine a good way ( maybe because I worked on Unity all day haha :rolleyes: )

    Any suggestions that could let me see this problem from another angle ?
     
  2. Jmanpie

    Jmanpie

    Joined:
    Oct 7, 2012
    Posts:
    132
    you will want to use way points and maybe use triggers to effect the physics. you could for example have trigger boxes near lights that tell the cars to slow too 0 by the tiem they get to the lights (maybe linear interpret the speed based on distance). and have a raycast from cars to detect there distance to the ones infrotn to say slwo down so they dont hti them.

    this could be useful i looked through it just then seems relevant:
     
    BrandyStarbrite likes this.
  3. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
    Thanks for that link, Mr. Jmanpie! :D
    I appreciate it!