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
1
Question by nsxdavid · Oct 06, 2011 at 10:59 PM · collisionphysicsbugcapsule

CapsuleCast colliding improperly

The Physics.CapsuleCast feature seems to be returning incorrect results.

For example:

 RaycastHit hit;
 Vector3 p1 = transform.position + Vector3.up * 2;
 Vector3 p2 = p1 + Vector3.up * 3;
 if (Physics.CapsuleCast(p1, p2, capsuleRadius, transform.forward, out hit, 10,mask.value)) {
   if(hit.point.y < p1.y)
     Debug.Log("Error!");
 }

The above code creates a capsule between p1 and p2 and casts it "forward". In this case p1 and p2 form a vertical capsule. And forward is therefore perpendicular to that. In no case, therefore, should a hit result in a Y point that is below p1. A vertical capsule casting horizontally could not possibly return a hit location lower than the capsule itself.

Yet it often does. :/

Is this a bug in Unity?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by aldonaletto · Oct 06, 2011 at 11:04 PM

I found a bug in the capsule collider that was studied more deeply by @Bunny83, and the whole thing is in the question The (ab)normal mystery. It seems the bug has not been fixed yet (despite it was reported to Unity then), and maybe it affects CapsuleCast as well - we didn't test it.

EDITED: I read your question more carefully, and it seems that you're not taking in account the capsule radius - according to the docs, p1 and p2 are the centers of the upper and lower spheres that compose your capsule, so the capsule extends from p1.y-radius to p2.y+radius. The bug mentioned above affects the normals calculated when the capsule collider is rotated around more than one axis.

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 nsxdavid · Oct 06, 2011 at 11:13 PM 0
Share

Indeed that does look like borked capsule collision. I will point out that PhysX itself doesn't have this problem inherently, so it's gotta be in the Unity implementation.

Not sure if it's related to this or not. But will try a different sort of collider.

avatar image aldonaletto · Oct 06, 2011 at 11:16 PM 0
Share

I've just edited my answer because I believe to had found the problem. Take a look at that.

avatar image
0

Answer by Owen-Reynolds · Oct 07, 2011 at 03:08 PM

This assumption: "...form a vertical capsule. And forward is therefore perpendicular to that." (italics mine) isn't correct.

Sure, since you use Vector3.up to build the two points, the capsule is guaranteed to be world-verticle. But, direction transform.forward still means what it always does -- your personal local forward vector (nothing to do with the capsule that will be constructed.)

If you're casting from a standard non-tilting charControlled object, then transform.forward is always flat, so the assumption is coincidentally correct, but for a rolling ball, say, you're casting in a random direction.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

IgnoreCollision affecting children & unrelated objects when it should'nt ? 0 Answers

Bug? ( failed collision from golf simulation ) 3 Answers

No bounce after rigidbody collision 2 Answers

AddForce to a point of a GameObject, not the center 1 Answer

Camera gets flung off of the map when the player collides with certain objects. 0 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