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 tomazsaraiva · Jun 28, 2010 at 10:45 AM · physicscollidercheckwaypointscapsule

FPS Tutorial Waypoints question

I'm following the FPS tutorial (from unity) to create a Waypoints system.

I've created the waypoint system and it works fine. My problem is that I need to reduce the distance so that each waypoint only connects to the closest waypoint and not to all waypoints around.

I found out that I can control which waypoints are connected with this:

public var kLineOfSightCapsuleRadius = 2.0;

function RecalculateConnectedWaypoints () { connected = Array();

 for (var other : AutoWayPoint in waypoints) {
     // Don't connect to ourselves
     if (other == this)
         continue;

     // Do we have a clear line of sight?
     if (!Physics.CheckCapsule(transform.position, other.transform.position, kLineOfSightCapsuleRadius)) {
         connected.Add(other);
     }
 }   

}

But I don't understand how the CheckCapsule works.

Thanks

Comment
Add comment · Show 2
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 Ricardo · Jun 28, 2010 at 12:05 PM 0
Share

I've re-tagged your question, as it wasn't actually AI related.

avatar image tomazsaraiva · Jun 28, 2010 at 12:09 PM 0
Share

ok...you're right..thanks

2 Replies

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

Answer by Ricardo · Jun 28, 2010 at 12:04 PM

You should check the documentation as it spells out what it does rather well. Or is there any part of the description that is unclear?

Update: Your confusion is not only on what CheckCapsule does, but how it's being used. It's used solely to check that there are no obstacles between transform.position and other other.transform.position in a tube of radius kLineOfSightCapsuleRadius. Reducing that value would only reduce the width of the tube that's checked for possible collisions. It does not by itself limit the connections to the shorter waypoint.

If you wish to do that, you should update the code yourself to:

  1. Check the distance between your waypoint and the one being evaluated.
  2. If smaller than the last smaller one found, save it.
  3. If not, move on to the next.

Once you're done with all waypoints, simply connect to the one found to have the shortest distance.

Comment
Add comment · Show 5 · 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 tomazsaraiva · Jun 28, 2010 at 12:07 PM 0
Share

Ricardo do you speak portuguese? it would be easier to communicate

I don't understand what this variable define: kLineOfSightCapsuleRadius

avatar image Ricardo · Jun 28, 2010 at 12:10 PM 0
Share

I'm afraid I do not, only Spanish. If you check the documentation, you'll see that it defines the radius for the capsule.

avatar image tomazsaraiva · Jun 28, 2010 at 12:11 PM 0
Share

ok..Yeah I understand that but by defining the radius of the capsule only the waypoints that collide with the capsule should be connected right? I have the waypoints 2 units apart..but even with a radius of 1 all waypoints are connected..even the ones that are realy far away

avatar image Ricardo · Jun 28, 2010 at 12:17 PM 0
Share

I see where your confusion is. I'll update my answer.

avatar image tomazsaraiva · Jun 28, 2010 at 12:28 PM 0
Share

ok..thanks..I'll try to do that

avatar image
0

Answer by tomazsaraiva · Jun 28, 2010 at 12:33 PM

I added this line of code and it seems to be working now:

if (!Physics.CheckCapsule(transform.position, other.transform.position, kLineOfSightCapsuleRadius)) {

         var distance = Vector3.Distance(transform.position, other.transform.position);

         if(distance < 2.1)
         {
             connected.Add(other);
         }
     }

Thanks Ricardo

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 Ricardo · Jun 28, 2010 at 12:42 PM 0
Share

No problem. Bear in $$anonymous$$d that will connect all waypoints within that distance, and not just the closest one (which you mentioned on your question you were going for).

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

No one has followed this question yet.

Related Questions

Physics objects sliding along surfaces 1 Answer

Camera gets flung off of the map when the player collides with certain objects. 0 Answers

Punching a crate 0 Answers

Only take into account colliders' bounds on single gameobject in hierarchy 1 Answer

Is it possible to allow a raycast to pass through a collider to hit things behind it? 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