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 TheOatyBiscuit · Dec 23, 2013 at 04:57 PM · randomwaypointobject follow path

Is this a good way to make a basic random waypoint system?

I started to develop some basic enemy AI and I decided I wanted my character not to have preset points to move to. So I learnt about the Random.insideUnitSphere function and used this to make one Waypoint which to a random point every few seconds. Since the character is always following it, the path always changes. It works well for me, but I just wanted to know whether it will be good when I add stuff like models and animations.

This is my script for moving the Waypoint:-

 // Update is called once per frame
 void Update () {
     waypointTimer -= Time.deltaTime;
     if(waypointTimer <= 0){
         waypointTimer = 2.0f;
         newWaypointlocation = Random.insideUnitSphere*10;
         Vector3 TP = transform.position;
         TP.x = newWaypointlocation.x;
         newWaypointlocation.y = 0;
         TP.z = newWaypointlocation.z;
         transform.position += newWaypointlocation;
     }
 }

}

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 Statement · Dec 23, 2013 at 07:18 PM

The only problem I can think of is that this may cause the AI to keep walking into obstacles, but otherwise I don't think it'll be a problem. It was also not what you asked for and you likely are aware of it.

Your AI probably have some motion controller that tries to steer toward the waypoint and can deal with animation when you have it.

As long as the behavior is what you want, at least for now, it looks good.

Since your AI presumably just walks toward a transform, your method is OK since you can change the behavior of the waypoint node without having to make changes to your AI.

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

19 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

Related Questions

How can I make an item choose between several different waypoints randomly and then make it execute something when it arrives to the waypoint? 3 Answers

choose random waypoint 1 Answer

Pause for random amount of time at waypoint 1 Answer

Random spawning in open environment 1 Answer

Wandering enemies 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