Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Some Simple AI Behaviors

Discussion in 'Made With Unity' started by spg, Nov 30, 2010.

  1. spg

    spg

    Joined:
    Aug 6, 2009
    Posts:
    79
    Hey guys, I was messing around with Unity 3 for the first time last night and put together a simple test level that includes a couple of different common AI behaviors. I thought maybe someone could get some use out of it, so I decided to post my project. If you're interested in creating some simple NPC AI behaviors but don't really know where to start... this might just help you out. No promises though. :)

    Click here to check it out.
     
  2. caldepen

    caldepen

    Guest

    Hi,

    This looks pretty cool. I ran through the webplayer version and will definitely check out the project (not at home at the moment). I plan on adding some wandering monsters to my game I am working on currently (offthepathgames.com) so this might be just the trick. I was reading part of the blog where you were discussing adding on to the AI by having them point at something rather than just straight ahead and was thinking that should be doable (by someone like me who might mess it up!) to have it point at a target rather than the way it is now.

    Thanks!

    Calvin
     
  3. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Hey ty. I'll check it out. Always interestd in AI.
     
  4. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Thanks SPG... any good AI help is always interesting! :)
     
  5. spg

    spg

    Joined:
    Aug 6, 2009
    Posts:
    79
    This should definitely be doable. I'm pretty sure there's some kind of aiming script already included in the Bootcamp demo, and there's always the headlook example - both of those should be solid resources in getting this done. Good luck!

    Steve
     
    Last edited: Nov 30, 2010
  6. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    A cool technique for these soldiers would be a Subsumption Architecture for the AI.

    Pseudocode I have in mind:
    Code (csharp):
    1. while( true )
    2. {
    3.   [FSM Layer 0] - Pathfinding
    4.   {
    5.     Location to move to = Find Path Somehow;
    6.   }
    7.  
    8.   [FSM Layer 1] - Individual Objective (Follow Player, Patrol with Buddies, etc.)
    9.   {
    10.     Location to Move To = Dot( Location to Move To, Other Position I'm keeping track of );
    11.  }
    12.  
    13.  MoveTowards( Location to Move To );
    14.  
    15.  yield;
    16. }
    I haven't downloaded your project file, but I'm having a great time with Subsumptive AIs in Zombies vs. Knights; it's proving so effective, I'm berating myself for not having tried it before.
     
  7. spg

    spg

    Joined:
    Aug 6, 2009
    Posts:
    79
    I haven't had a chance to try out a subsumption architecture in a game yet (only a project in college), but it's on my list to try out for a while. Maybe I'll give it a shot and post another project...
     
  8. bradjensen68

    bradjensen68

    Joined:
    Feb 2, 2009
    Posts:
    274
    I dropped wander code on one of my characters and now he wants to fly up in the air! Is there a way to control which axis they are using?

    I should add that the follow behavior works fine.
     
    Last edited: Jan 27, 2011
  9. Din

    Din

    Joined:
    Jan 11, 2011
    Posts:
    146
    Why follow AI ignore collisions when the surface is not flat
     
  10. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    Very nice!

    I especially like the guy that follows you if you go too far away from him! I'll be checking that out!
     
  11. Kinos141

    Kinos141

    Joined:
    Jun 22, 2011
    Posts:
    969
    This is good. I was working with it, and figured you can use CharacterController.SimpleMove(Vector3). I adds gravity, collision and movement.
     
  12. spg

    spg

    Joined:
    Aug 6, 2009
    Posts:
    79
  13. spg

    spg

    Joined:
    Aug 6, 2009
    Posts:
    79
    I know this is very old, but I just updated this project to deal with y-values better because I keep getting emails about it =)
     
  14. soulreafer22

    soulreafer22

    Joined:
    May 12, 2015
    Posts:
    15
    drop box down :-(
     
  15. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Congratulations! You have won:

    :D
     
  16. soulreafer22

    soulreafer22

    Joined:
    May 12, 2015
    Posts:
    15
    cool but this is not what i digged for
     
  17. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,821
    It's the result you deserve, not the result you need.

     
    JamesLeeNZ likes this.