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 dansav · Dec 08, 2012 at 04:03 AM · boundsinsideoutside

determine nearest y outside of mesh from point.y inside

Is it possible to determine the distance from a point inside a mesh to the first point outside the mesh in each direction (x,y,z).

For example: I have a rigged character with an arm bone. I want to know the nearest distance in x,y,z from the arm bone transform position to the outside of the mesh. Is there an easy way to do that?

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

1 Reply

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

Answer by lil_billy · Dec 09, 2012 at 03:58 PM

No, Raycast would have been the only solution but there are a bunch of things preventing that first you would be casting from inside out which it wont detect properly, second youd have to use a mesh collider which isnt ever reliable to begin with.

The other option would be to manually run your mesh through the mesh class where you would then have to dedicate a lot of time to figure out how to sort all that data in order to find the indicies or triangles that you are looking for (have positions closest to the position of your joint). Its doable but mind numbing.

other option thats a bit of hack in comparison

-create 3 GOs child them to the joint you are targeting

  • set them to whatever axis you are testing on either local or world (your choice)

  • set them OUTSIDE OF YOUR mesh

  • put a mesh collider on your character try to ensure it is as good as it could be, there are some importation options that affect this

  • then raycastall from those points towards your joint

  • store the info in a raycastHit

  • then do hit.distance which will give you the distance from your cast to where it hit on the mesh (assuming it worked with mesh collider(its spotty))

  • then get the Vector3 distance from your cast point position and your joint position

  • subtract the 2 distances and you get what you were looking for

  • REALLY NOT EFFICIENT TO BE DONE CONTINUOUSLY

  • not guaranteed to work 100% of the time because of mesh collider (70-90% success)

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 dansav · Dec 10, 2012 at 06:42 AM 0
Share

I think that's a great idea to use the three game objects as sensors. I'll try it.

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

10 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

Related Questions

Receiving String from Variable in other Object 3 Answers

Position inside or outside of custom shape (select object if inside custom drawn selection) 0 Answers

how can i detect when my gameobject is completely inside of another gameobject? 2 Answers

Get position of the centre of each grid tile 1 Answer

How can I consistently get the rectangle bounds around a mesh? 2 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