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 Ninita · Feb 10, 2013 at 11:58 PM · movementlocomotionbots

how to confine the displacement of a bot to a certain space?

Hi, how do you confine the displacement of a bot to a certain space? I've seen examples of project Mecanim Example Scenes, but not really helped me. See the picture below. I want my bot only walks in the green areas. How do I do that? Through mathematical formulas? I tried by creating gameObjects these areas but do not know how to access all of its points :S

 System.Collections.Generic.List<Vector3> listPoints = new System.Collections.Generic.List<Vector3>();
 
 foreach (Vector3 p in area.transform)
        listPoints .Add(p);
 
 int rand = UnityEngine.Random.Range(1, listPoints .Count);
 posDestiny.x = listPoints [rand].x;
 posDestiny.y = 0;
 posDestiny.z = listPoints [rand].z;


P.S.: Sorry i could not load the image, I had to do otherwise: [1]: /storage/temp/7721-areas.pdf

areas.pdf (83.1 kB)
Comment
Add comment · Show 8
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 robertbu · Feb 11, 2013 at 02:10 AM 1
Share

I'm unclear about the problem. What is moving the bot? Script? Animation? What does listPoints represent? Is posDestiny the next point the bot is to go or something else? It is pretty easy to test whether a position is in the green or red areas if that is all you need to know.

avatar image Fattie · Feb 11, 2013 at 10:09 AM 1
Share

http://docs.unity3d.com/Documentation/ScriptReference/Random-insideUnitSphere.html

avatar image robertbu · Feb 11, 2013 at 07:56 PM 1
Share

You can easily calculate if a point is in the green or the red, and therefore you can make sure that any end points that he would travel to will be in the green. But the issue becomes more complex if you have to make sure NPC does not cross the red. You are looking at obstacle-avoidance or pathfinding algorithms. You description of listPoints does not make sense to me in the Unity world. You might be able to do something with the mesh of the collider to figure out a set of possible points, but given your description, a math model might be better.

avatar image robertbu · Feb 11, 2013 at 09:22 PM 1
Share

A box collider and a capsule collider appropriately placed can overlay the red area. When your NPC will get a OnCollisionEnter() when he attempts to enter the space, or you can check ahead of time by doing a Physics.Raycast().

avatar image robertbu · Feb 13, 2013 at 04:56 PM 1
Share

No personal experiences, but I believe with a CharacterController you use OnControllerColliderHit(). Raycasting will work either way.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by ThePunisher · Feb 11, 2013 at 09:24 PM

If you are using the pro version why don't you save yourself the headache of writing a custom solution for that and use the NavMesh feature? It will be so much simpler to define areas your bots can and cant' access.

Watch the video I linked you and if that's the behavior you are looking for (towards the end), then I would recommend using NavMesh.

http://docs.unity3d.com/Documentation/Manual/NavmeshandPathfinding.html http://www.youtube.com/watch?v=TBYviGlF1hI

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

11 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

Related Questions

How to create a movement system for a bot? 0 Answers

Grid Based Movement (Pokemon-like) 1 Answer

Understand how locomotation system works 1 Answer

Locomotion System Character Animation Question 1 Answer

Player Climbing a Ladder? 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