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 Kevin_C · May 31, 2012 at 05:35 PM · aipathfindingrooms

dynamic node driven room based AI

any place marked with (*) are shaky points, and I would appreciate correction if need be.

Setup: my game is a maze-type game using prefab defined rooms that are proceduraly placed (a levelManager will be controlling this). I know that there is a path-node system in Unity, but as far as I can tell it requires baking*, and also contradicts some of my desired functionality (see below). So I have placed Nodes into my prefabs at desired points (currently Empty GameObjects).

Problem space: I want to have my agents be able to move around the room that they are created in using the nodes (wandering), and not be aware of the nodes in the adjacent rooms unless told to take a calculated node path to a target (hunting). then if need be return to their starting room (traveling) via reverse path.

reasoning: because the built in path node system needs baking*, and I want to have the agents only know of a subset of all nodes at any given time (unless given a different subset) I think I will need to roll my own node system.

Question how would I create an extensible node system that can run dynamically?

*what I think it will need is that all nodes will need to be a node layer, and that each have a given script. I think that I can have each agent locate local nodes with radius raycasts, but that will not be limited to the given subset unless I am missing something. I thought that I could get around some of this by having the rooms be their own data structure (this thought comes from a C++ OOP mindset), but I don't think that Unity will allow this the same way that I would like as it seems to me that all Objects are aware of everything unless the layers say otherwise, and I don't want to have to have a different layer for each room (mainly because it might not be a fixed number of rooms)

Comment
Add comment · Show 3
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 whydoidoit · May 31, 2012 at 06:02 PM 0
Share

Just as a thought - I use the A* Path Finding Project from the Asset Store - that does not require baking and enables maps to be updated as levels evolve.

avatar image Kevin_C · May 31, 2012 at 07:04 PM 0
Share

@whydoidoit, but that doesn't account for the constraint of limiting agents knowledge to the current room.

avatar image whydoidoit · May 31, 2012 at 07:36 PM 0
Share

So is that really two problems - one is agent navigation in a dynamic environment and the other is selection of potential targets for destinations?

That's how I deal with this - slightly different. $$anonymous$$y characters have memories and use them in their decision making - but I'm treating locations as a list of places that they remember or have been told about. Then when they make a destination decision they only need to call the pathfinding for how to get there. For them they don't care about the physical location of targets or their navigability - because that is ensured (actually they do make some decisions based on distance, but this is cached and available to all of them as a lookup).

So my targeting is straightforward list processing and weighting and my navigation is A*

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by Loius · May 31, 2012 at 08:17 PM

When I built a similar solution, I made my Nodes 'intelligent.'

On creation or when moved, a Node compiles and stores a list of adjacent Nodes. If that list has changed since last time, it tells the Path Manager so Paths can update.

When a Room is created, it gets all the Nodes inside itself, then builds a directional Path over those nodes.

Agents request directional Paths (From the Room when wandering, or from the Path Manager when hunting). This way an Agent only knows about its current Path (which translates to only knowing about the room it's in)

The Path Manager does all the heavy lifting of finding paths (and listening for moving nodes and adjusting accordingly); the Agents just happily run along the list of Nodes they're given. Once they reach the end they either loop to the beginning (wander) or do the 'where is Player?!' logic again and either get a new Path or go backwards along the one they have.

Comment
Add comment · Show 3 · 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 Kevin_C · Jun 02, 2012 at 02:54 PM 0
Share

@Vicenti I understand what your saying, but I am unsure how to implement it. are there any examples, or tutorials on how to do this. I will have a Level$$anonymous$$anager that will have all the rooms so do these managers have to exist in parallel, or in composition (then how does one know about the other?),

and how would communication work between them?

avatar image Loius · Jun 04, 2012 at 10:51 PM 0
Share

Not sure there's any tutorials or anything, it was kindof completely homespun. :)

It should be pretty simple, though, if you object-ify as much as possible.

Agents should know what Room they're in. They can ask Room.Path to get their wander path, which is a link to a path (not an actual path) managed by the path manager (so when nodes move and the paths change, the agent doesn't need to hear about it).

I actually created my room paths manually rather than attempt a programmatic construction (since many of the nodes have line-of-sight to others).

To get a node's adjacent nodes, I just used physics.raycasts with a distance limit to find nearby nodes. Nodes have to be a little off the floor so they can see down inclines.

avatar image Kevin_C · Jun 09, 2012 at 09:46 PM 0
Share

I think I am understanding, but I am a little lost on the implementation. like how is that my agent considers the nodes in view, but ignores the ones that are occluded by walls?

on top of that I understand what the Path$$anonymous$$anager is supposed to do, but I am a little lost on how to go about it. could I please see even a stripped down commented version of this Path$$anonymous$$anager class/script?

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

6 People are following this question.

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

Related Questions

Evade a Collider on Vector3.forward 3 Answers

AI Avoidance Problem 1 Answer

Entegrating AIFollow.cs and Wayfinder.js (A* Pathfinding Aron) 0 Answers

Movement around a huge object by avoiding obstacles 1 Answer

Have falling object exit from a collider after collision? 2 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