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

Need help with FPS AI

Discussion in 'Scripting' started by TRALLALAL, Jul 13, 2014.

  1. TRALLALAL

    TRALLALAL

    Joined:
    Sep 7, 2013
    Posts:
    132
    I'm working on a small FPS game, it's a simple mission which lasts like 5 minutes, just for practice.
    I know how to do everything except for the AI, I would like some tips from people who know AI so I have a few questions.

    1) Waypoints
    I think waypoints would be pretty simple, I would store them in an array then check their distance, if it's less than 5 enable the next waypoint, would that work?
    2) Firefights
    This is the hardest part IMO and I don't know from where I should start, how do I tell the AI who a NPC should shoot? Do I store the enemies in an array and pick a random one?
    3) Covering system
    At the moment animations are not the problem as I will work with them in the future, but still I don't know what to do, should I scan for the closest object and change the NPC stance based on what the object is?
    4) Firing system
    I think this is pretty easy, it would be similar to the player's gun system I think, I just have to set their rotation, would a simple lookAt(target) work?
    5) Pathfinding
    I know nothing about this, I don't want the AI to stop moving as soon as the enemy is met, any tips?

    Thanks for all the help.
     
  2. Magiichan

    Magiichan

    Joined:
    Jan 5, 2014
    Posts:
    403
  3. TRALLALAL

    TRALLALAL

    Joined:
    Sep 7, 2013
    Posts:
    132
    Uhm actually I would like to learn, I thought that was a tutorial but it's a downloadable AI so that's not what I was looking for.
    Thanks still
     
  4. Fluzing

    Fluzing

    Joined:
    Apr 5, 2013
    Posts:
    815
    Quote:" 5) Pathfinding
    I know nothing about this, I don't want the AI to stop moving as soon as the enemy is met, any tips?"

    Search for Navmeshes or Astar Pathfinding. This is the single most important thing to learn when programming AI. Noone here will do it for you, you will have to find out how it works yourself.
     
  5. TRALLALAL

    TRALLALAL

    Joined:
    Sep 7, 2013
    Posts:
    132
    Read my post above, I wasn't looking for something done I was asking where I should start.
     
  6. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,548
    Check out the Stealth example project. It covers a lot about AI.

    I guess that should be a good place to start.
     
  7. TRALLALAL

    TRALLALAL

    Joined:
    Sep 7, 2013
    Posts:
    132
    Thanks a lot, it seems good :)
     
  8. Magiichan

    Magiichan

    Joined:
    Jan 5, 2014
    Posts:
    403
  9. Pysassin

    Pysassin

    Joined:
    Dec 27, 2012
    Posts:
    87
    If the level isn't changing much in-game navmesh system would make easy work of the waypoint/pathfinding issues. The rest is pretty hard to tell you what is best as it is REALLY dependent on the system you are running and the effects you are hoping to achieve. I know for simplicity's sake when dealing with cover spots you can just use empty objects with a cover tag or layer on them and use a sphere cast to see if any cover is close when the AI decides they need to run and hide. Shooting can be equally complicated especially depending on how it is handled for the player etc. But yes a LookAt option can be as viable as any.