• 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 Thor625 · Jul 01, 2013 at 03:19 PM · javascriptaienemywaypointenemyai

Waypoint System help

Hello,

I have my enemy that follows the player around when he gets into a certain range. When there is no target nearby/if he loses/kills the target, he should walk aimlessly around. When he is walking around, he should pick a random nearby waypoint, go to it, then pick another, go to it, and repeat. How would I do t$$anonymous$$s? I have thought to have a bunch of waypoints that each have a list of other waypoints they connect to, but there must be a quicker way.

All help is appreciated,

Thanks,

Thor

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

1 Reply

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

Answer by Travis-Bulford · Jul 01, 2013 at 03:37 PM

Hi Thor,

You can consider using Random to generate a way-point from your current point.

Assuming your point would be x,z and y is the altitude you could great a Vector3(x+Random.value*20f-10f,-WAYABOVETERRAINT,z+Random.value*20f-10f) way above the terrain and ray-cast down to get the y at the coordinate. (One issue will be if there is a suitable path to that point.

Generally we try keep tack of our mobs home point if the chasing the player they will return to there "home" location before roaming. Then roaming random points would only be generated wit$$anonymous$$n a radius of there home point. (you can do t$$anonymous$$s easily with some trig, generate a random angle and radius from home then do the above ray-cast to find the complete vector.) A more sop$$anonymous$$sticated roam would only adjust the current movement angle always tending towards the home location but not completely rotating.

Without more information of your game world environment it will be difficult to give more advice.

Comment
Add comment · Show 2 · 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 Thor625 · Jul 01, 2013 at 09:16 PM 0
Share

The environment has many stairs, so there won't be a suitable path to most points. It is basically a city, so there are a ton of buildings that the enemies can go up stairs on. I hope that helps. Thanks

avatar image Travis-Bulford · Jul 02, 2013 at 04:58 PM 0
Share

How do you path find? Are you using a node based a* solution? If so you could search nodes nearby 2 or 3 at a time the first that's path-able use that.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

How to make the enemy move back to its waypoint after it's target killed? 2 Answers

How to make enemy attack multiple unit rather then single?(updated) 1 Answer

Problem with the movement of AI 1 Answer

AI Waypoint help or suggestions!? 2 Answers

Enemy not rotating when inside range 1 Answer


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