Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Feref2 · Jan 11, 2020 at 08:24 PM · collidercentermesh verticesedge detection

How to get the center of a collider face and the halfExtents to the corners of that face?

So my original plan was to get this this info with a racasthit, look for the center of the collided line (or rectangle if it´s 3d) and then just compare how close it was to the edges also getting the halfExtents. But there raycasthit doesn´t have any properties to get the center or edges, and am not even sure if that´s possible. alt text

So the green outline would be the collider and the red dots the positions I want to get. As you can see, they aren´t the edges of the collided rectangle/triangle. They are the corners of each straight line composed by the collider. Is there a way of doing this?

This is to check if the player is grounded. I was originally doing a checkBox, but is not accurate enough to check for very inclined plane collisions. (In fact, the y scale needs to become very big if it´s very close to 90 degrees). I could increase the x scale, but then the object would realize late that is not on a platform once it reaches the end. Please don´t suggest anything related to physics system: am not using it. (And I tried OnCollisionExit and it still gave undesired effects). Besides, this solution of getting the corners of a straight line also solves other issues, like if the player is on the slope, but the checkBox isn´t (if it´s too inclined and the collision point is on the arm, for example).

If there´s no way of getting the collider vertex, the mesh vertex still works.

captura-de-pantalla-67.png (184.0 kB)
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 sacredgeometry · Jan 17, 2020 at 08:09 AM 0
Share

Is there scope to reduce the resolution so that it is one face? ins$$anonymous$$d of 9 (for just the top edge)? i.e. two triangles. It would probably be a good optimisation as having that many polys to define a straight line (what is essentially a quad) may be a bit unnecessary.

It would also make this and other problems trivial.

avatar image Feref2 sacredgeometry · Jan 17, 2020 at 09:56 AM 0
Share

That was just an example. I know that in this specific case is a bit unnecessary to have that many polys, but in other cases where the geometry might be complex for whatever reason you can´t do that. And still, how to get the distance between those vertices? The collider apparently doesn´t have that info and if they aren´t the max distance you can´t get them checking the scale. alt text

And a straight line isn´t necessarily composed by a single edge (see the lowest line). To make that kind of polygon, you need to break it down to a bunch of quads and triangles (am not entirely sure if that image is completely accurate, but it proves my point).

I thought to maybe decompose that polygon into separate pieces and then parenting them, but I don´t think that colliders would match it perfectly and I would end up spending more resources than necessary. In the previous case I would normally use a mesh collider; but if it´s separated I would need more of them, since box colliders don´t work with slopes (and I think that having several mesh colliders imitating the same figure than a single mesh collider is worst for performance, since you are increasing the amount of vertices of an already expensive collider, but am not entirely sure of this).

captura-de-pantalla-71.png (196.5 kB)

0 Replies

· Add your reply
  • Sort: 

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

152 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 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 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 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 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 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 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 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

FPS collider center offsets camera pivot? 0 Answers

How to get center of collider in hierarchy 3 Answers

how to change sphere/capsule collider, it sizes and the center 2 Answers

Internal collisions 1 Answer

How to Instantiate GameObject on top of collider? (C# 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