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 Tyrebear · Feb 19, 2014 at 01:57 AM · followartificial intelligencewaypointswaitmanagement

How can I make the AI in my game wait in lines?

  1. Hello I am making a 2.5D isometric restaurant management game where the player controls the inner working of their own restaurant. What I am having trouble doing and finding information about is making the customers of my game wait in lines and stop behind each other when there is already somebody occupying the way point or space in front of them.

  2. Because it is supposed to be a restaurant the AI needs to wait in line just like in real life.

  3. I'm not sure if it will help but here is a copy of my script that allows the customers to seek out way points and act in a semi-believable way. I use a nav mesh for the detection of objects.


    var waypoints : Transform[]; var waypoint : Transform; var currentWaypoint : int; var agent : NavMeshAgent;

    function Awake(){ agent = gameObject.GetComponent.(); agent.speed = Random.Range(2.5, 5); }

    function Update () { waypoint = waypoints[currentWaypoint]; agent.SetDestination(waypoint.position); }

    function OnTriggerExit(other : Collider){ if (other.name == "0 Start"){ currentWaypoint = Random.Range(1, 3); } }

    function OnTriggerEnter (other : Collider) { EatMeal(); if (other.name == "0 Start" || other.name == "3"){ currentWaypoint++; } if (other.name == "1"){ WaitForSoda(); Debug.Log("Is Waiting"); } if (other.name == "2"){ WaitForFood(); Debug.Log("Is Waiting"); } if (other.name == "4 End"){ Destroy(gameObject); } }

    function WaitForSoda(){ yield WaitForSeconds(2); currentWaypoint++; }

    function WaitForFood(){ yield WaitForSeconds(5); currentWaypoint = Random.Range(5, 12); }

    function EatMeal(){ if (currentWaypoint >= 4 && currentWaypoint <= 12){ yield WaitForSeconds(Random.Range(5, 12)); currentWaypoint = 3; } }

Comment
Add comment · Show 6
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 getyour411 · Feb 19, 2014 at 01:58 AM 0
Share

Format code using 10101 button please

avatar image Tyrebear · Feb 19, 2014 at 02:02 AM 0
Share

I can't get it to format correctly :/

avatar image robertbu · Feb 19, 2014 at 02:04 AM 0
Share

For some reason, code does not format correctly after lists. So putting any kind of non-list paragraph after the list fixes the problem.

avatar image Tyrebear · Feb 19, 2014 at 02:05 AM 0
Share

hm, well i guess it fixed itself or a moderator helped me :P

avatar image theMonster · Feb 19, 2014 at 02:16 AM 0
Share

Which part specifically of your script is not working?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by theMonster · Feb 19, 2014 at 03:45 AM

The easiest thing then is to make a "Threshold" script. The Threshold script will have a function called "isThreshHoldMet", "registerForThreshold", "unregisterForThreshold". Let me know if you have any questions on actual implementation, but it should be pretty straight forward.

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 Tyrebear · Feb 19, 2014 at 05:54 AM 0
Share

Hm that is an interesting solution however I can't seem to find documentation on the implementation, therefore you will have to clarify what the variables registerForThreshold and unregisterForThreshold will do. Thanks :)

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

20 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

Related Questions

How to assign a transform object to Prefab ? 3 Answers

Is this an [optimal, adequate, ftarded] way to make a snake follow its head? 2 Answers

Enemy Follow Player 1 Answer

How can I make more than one AI entity prefab to move or activate? 0 Answers

Camera rotation around player while following. 6 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