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 Tocs · Jul 09, 2013 at 08:41 PM · collisionphysicscapsulecastcapsulecastall

Test stationary capsule against colliders in scene.

I have a capsule defined by two end points and a radius. I would like to query the scene for any collisions with this capsule and retrieve the collision point and normal.

Note: Physics.CapsuleCastAll (p1,q1, Radius, Vector3.zero); Does not produce any hits.

Note: Physics.CapsuleCastAll (p1,q1, Radius, Vector3.up, 0); Doesn't produce any hits.

This appears to be erroneous as a capsule has a defined volume and whether or not I've dragged it through space shouldn't be relevant to if it intersects things.

I'd rather not write capsule tests for all the shapes in Unity and manually test the scene. So how do I query Unity for this information?

Motivations for my approach:

I'm implementing thread simulation via position based dynamics. I have a thread composed of nodes which each have a mass and velocity, position, and torsion. I solve a set of constraint equations to make the thread behave as one would expect. The space between two connected nodes forms a capsule shape. Since the thread has radius, and two nodes have two points I get a capsule. I handle self-collisions internally but in order to integrate it into unity's physics I need to get collision data for these capsules.

Why I can't use a GameObject:

If I wanted to use a GameObject I would have to create an object for each space inbetween nodes. I would have to use a non-kinematic rigidbody for this intermediary spaces between nodes (Or else I wouldn't get collisions against static shapes). Which in lies the first problem, the capsules aren't rigid they change size every frame. I'd have to update a rigid body each frame with approximated values for velocity, mass, inertial tensor, etc... The capsules don't behave that way. I'd be forming a bridge which would introduce further error into the simulation. I can't have that messing with my thread. I need a way to query the scene for the data to handle the collisions myself. How do I accomplish this?

Comment
Add comment · Show 1
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 Tocs · Jul 12, 2013 at 07:19 PM 0
Share

A solution would be awesome, I've tried everything, this project is on a deadline, and this has to work. I really need help from the Unity community because I'm out of ideas. There seems to be a habit on this answer site of overlooking the question. In this case I mean exactly what I'm asking. I need a function that returns the normal and intersection point with colliders in the scene for a capsule. Not a component, not an object, a function.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by supercouge · Jul 09, 2013 at 10:19 PM

I may have misunderstanding your question, but if you want to get the collision from a capsule gameObject, attach a capsuleCollider and a rigidbody to it. Then attach a script with the OnCollisionEnter(Collision collision) function.

Comment
Add comment · Show 4 · 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 Tocs · Jul 09, 2013 at 10:31 PM 0
Share

Good thought. But this wont work, I don't have a GameObject for each capsule. Nor does the design warrant a GameObject for each capsule.

avatar image supercouge · Jul 10, 2013 at 09:15 AM 0
Share

Even if you instantiate your capsules with no renderer?

avatar image Tocs · Jul 10, 2013 at 02:43 PM 0
Share

The capsules aren't objects and shouldn't be objects. They're simply two points in space who represent a volume that I need to query. They're part of a single larger amorphous self colliding object. If I were to create game objects for each capsule I would have to worry about many many more issues than if I can just query the scene for a capsule shape. Its hard to explain, but I CANNOT use a game object purely for the capsule collision. It just doesn't work.

avatar image Tocs · Jul 10, 2013 at 03:44 PM 0
Share

Think Physics.CheckCapsule but with intersection information.

avatar image
0

Answer by shaderop · Jul 10, 2013 at 05:53 PM

I ran into a similar situation a while back where I really needed to get all colliders intersecting a capsule. It's not really obvious from the documentation, but CapsuleCastAll needs a distance greater than zero to return any results, and apparently the results it will return are what colliders would intersect the capsule if it was moved by distance along direction, which isn't what I needed and it seems it's not what you need either.

In the end I got around it by approximating the shape of the capsule using spheres and calling Physics.OverlapSphere on each sphere. It was more than a good enough approximation for my use case, and I'd venture to guess that it should be enough for yours as well.

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 Tocs · Jul 10, 2013 at 06:26 PM 0
Share

I might end up having to do something similar. I'd hate to have to write all the collision tests myself. The issue is I'm "appending" to the physics capabilities. Something that's not a rigid body and I do need the point and normal of collision. I don't want to use GameObjects for every little section of the thing. They're created and destroyed frequently change size overlap neighboring sections. GameObjects are big and bloated and there's a ton of them. Additionally the capsules aren't even the objects they're the space between them so creating GameObjects to get collision is just sloppy. Again good thought, but still not exactly what I need.

avatar image shaderop · Jul 10, 2013 at 06:50 PM 0
Share

Just to clarify, when I said "approximate using sphere," I didn't mean actual game objects with spherical colliders. I meant conceptual sphere that only exist as centers and radii, which is all the information that OverlapSphere needs.

Anyways, good luck with finding a solution that works for you.

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

17 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

Related Questions

How to keep CapsuleCast() from sweeping? 2 Answers

CapsuleCastAll fails after 20 calls 1 Answer

Disable/Enable Colliders 1 Answer

CapsuleCast colliding improperly 2 Answers

Gun collision problem 3 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