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 GameTech · Jan 06, 2013 at 12:31 AM · aipathfindingwaypointfollow player

Is this pathfinding waypoint based AI script viable?

So I am learning programming (so keep an open mind I don't know A* or other complicated algorithms) and building a simple AI follow player script that would allow it to avoid obstacles that don't move. Basically I have a bunch of transform nodes that can reach another node in a straight path so the ai can follow it like an ant trail.

With another script this can be adjusted so that waypoints can automatically and dynamically be created allowing the AI to avoid moving, new, different obstacles during the game. I can write a script that takes every obstacle and create waypoints around or inside depending on tag, etc, and was wondering about performance of doing all this checking only on new, moving, different obstacles every second or frame?

It works by sending a superfast scout following nodes to scout all available nodes and ends at the one closest to the player (leaving a straight path to the player). The nodes will basically use OnTriggerEnter() to add the trail to the AI's path array or remove every node after if it already traverse it, which the AI follows like an ant.

I want to know if OnTriggerEnter() always works even if something zooms through it at lightning speed, (the scout will move super fast since pathfinding needs to be updated for player position). I also want to know the general performance of using multiple scouts for multiple enemies and doing this like every 3 seconds or every node? Is this viable as a pathfinding solution? or should I just use A* and other pathfinding methods?

Comment
Add comment · Show 4
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 Lovrenc · Jan 06, 2013 at 12:42 AM 0
Share

Super fast object pass trough other objects and also cant trigger event. I wonder why you are even using on trigger enter. Such things should be done as backlogic on data that represents it in efficient manner.

avatar image GameTech · Jan 06, 2013 at 01:28 AM 0
Share

The scout will only follow the nodes so it wouldn't go through objects, but you are saying it doesn't trigger a collider? I am only using on trigger enter to make a very easy to understand script because I am not that good at program$$anonymous$$g yet, and there doesn't seem to exist simple pathfinding scripts.

avatar image Lovrenc · Jan 06, 2013 at 01:44 AM 0
Share

I must say i am not exactly sure what you are doing. But anyways just to answer your title. Wayspoints are just fine for pathfinding. Even if you were to implement A* you could use them to represent your grid.

If i understand correctly, you send a "scout", scout splits at every crossway, for each node you check the distance from the player, and when you check all nodes it returns closest one?

If this works for you then good. It seems highly unefficial and it doesent return closest path (unless you are also su$$anonymous$$g the travel distance).

To answer your performance question for multiple enemies. It could be a problem doing it like this if your waypoints grow in quantity. Since you are checking every possible root (how are you preventing cycles?) this can become really slow. Doing it once every 3 seconds wont help much either. It could make your game frozen for short period of time. Every three seconds. Usually pathfinding is done over multiple frames.

If i am imagining your algorithm incorectlly, please elaborate.

avatar image GameTech · Jan 06, 2013 at 02:48 AM 0
Share

So it goes sorta like this. Scout(a moving collider) starts at Transform closest to AI object. Transforms are going to be put into arrays for easy traversing in order. It uses Vector3.distance(a,b) to deter$$anonymous$$e distance from player. It stops after finding the Tranform closest to player and sends a Tranform Array to AI object. The transform array is constructed by adding each Transform that the scout collides with, if it collided with the Tranform before, it will delete the indexes after the position of that Tranform in its array. The AI object simply goes towards each Transform in the array, and if close enough to player will simply follow player directly and if path is obstructed, starts the scout again. It does require going through multiple arrays multiple times though to get all this information...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Tapp · Jan 27, 2013 at 02:17 PM

If I understand you correctly you want your AI to find its way around objects to your Player, a simple way to do this would be to have the Player trigger the nodes (leaving your 'Ant Trail' as you called it) and then have the AI follow this path to the Player, you could use find nearest to allow the AI to find the closest node.

Implementing it properly would need testing obviously.

Comment
Add comment · 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

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

10 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

Related Questions

Why isn't a Ai Waypoint Spawning??? 0 Answers

How can I make AI follow waypoints and choose random ones? 1 Answer

RTS dynamic formation width and length 0 Answers

Sidescroller AI/Pathfinding/Flags/Waypoints 0 Answers

Help with a simple AI 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