Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by coolbird22 · Aug 17, 2014 at 04:59 PM · aipathfindingnavigationchase

How do you create an AI that works like this ?

I'm referring to the game 'Gesundheit' - Gameplay Link. The game is very sprite heavy. How is it possible to create Navigation Meshes for a game like that ? Also, how do you create a constant field of view check for the monsters, to check if the player is currently visible or not ? Does such a behavior require pathfinding algorithms, or is it possible to plain code them ? How is it possible to code a behavior that if the player escapes out of the sight of the monster, that the monster will give up chasing the player and go back to rest, like in the gameplay video ?

I apologize if I'm asking too many questions inside a single one, though I feel that there is a possible singular answer to it. It would be great if you could point out some useful resources that I could refer to, to achieve this. Also, I do not wish to use other plugins/assets from the Asset Store.

Thanks for taking the time to read this.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image louisgv · Aug 18, 2014 at 07:53 AM 0
Share

Also, how do you create a constant field of view check for the monsters, to check if the player is currently visible or not ? Does such a behavior require pathfinding algorithms, or is it possible to plain code them ? How is it possible to code a behavior that if the player escapes out of the sight of the monster, that the monster will give up chasing the player and go back to rest, like in the gameplay video ?

Imo, you migh want to take a look at raycast to see if either player or some object is near, then use a simple path-finding to go toward that place.

Good luck!

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Cherno · Aug 18, 2014 at 01:13 AM

1) How is it possible to create Navigation Meshes for a game like that ?

I recommend the "Astar Pathfinding Project". The basic version is free and very powerful. If you don't want to use any resources from the Asset Store, well, good luck to you, and use Unity's own NavMesh feature.

2) Also, how do you create a constant field of view check for the monsters, to check if the player is currently visible or not?

 var fov : float = 60.0f;
 var maxDistance : float = 10.0f;
 var blockLayerMask : LayerMask;
 
 function CheckLoSHitBox (target : GameObject) : boolean 
 {
     if (Vector3.Angle(target.transform.position - transform.position, transform.forward) <= fov)
     {
         if(Vector3.Distance(transform.position, target.transform.position) <= maxDistance)
         {
                 var hit : RaycastHit;
             if(Physics.Linecast(transform.position, target.transform.position, hit, blockLayerMask) == false)
             {
                 Debug.DrawLine (transform.position, target.transform.position, Color.white);
                 return true;
                 
                 //hitting the actual target is not needed to "see" it! if the ray is not blocked by obstacles or ground, that's enough!
 
             }
         }
     }
     Debug.DrawLine (transform.position, target.transform.position, Color.red);
     return false;
 }


3) Does such a behavior require pathfinding algorithms, or is it possible to plain code them ?

What kind of behavior do you mean? You can check if the monsters see the player, and then give their pathfinding script the player's position as a target position, and make them start moving toward him or her.

4) Easy; if the monster is no longer seeing the player, it just returns to it's starting position or maybe roam around randomly. You just set a boolean "seeingPlayer" to true if the FoV-check above returns true, and to false if it doesn't. It's enough to check every second or so, you don'T have to call it every frame.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image coolbird22 · Aug 23, 2014 at 05:47 PM 0
Share

Thanks for replying to this. You pretty much answered all of my questions. I was assu$$anonymous$$g that A* Pathfinding was a paid asset. I'll look into the free version. Thanks yet again !

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Navmesh agent stuck on partial path 0 Answers

How to build a custom shape NavMesh Area 1 Answer

using a Mesh Volume for AI 1 Answer

Make a flying enemy ? 0 Answers

How to do AI pathfinding on trees and other vertical surfaces? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges