• 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 /
This question was closed Nov 09, 2015 at 05:31 PM by jmgek.
avatar image
0
Question by jmgek · Nov 08, 2015 at 01:39 AM · localposition

How can I get the position of a Vertex on a surface?

I am going through my mesh and I need to return the position of one of them in world space. Vector3.Position() I am able to get a position with something like this:

 Vector3 vertPos = gameobj.transform.position + transform.TransformDirection(meshVerts[0]);

But for something like this it wont work if I rotate the object.

I am unable to return a vector3 in world coordinates with transform.TransformDirection() or transform.TransformPoint() Is this a bug or am I doing something wrong?

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

  • Sort: 
avatar image
2

Answer by JoshuaMcKenzie · Nov 08, 2015 at 04:22 AM

I think what your looking for is

 Vector3 vertPos = transform.TransformPoint(meshVerts[0]);

That takes a point in space that is relative to the Transform's origin and converts it to world space.

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 jmgek · Nov 09, 2015 at 04:07 AM 0
Share

This does not work for me for a Vertex, it just returns me the actual vector3 on the surface. Do you know if this is a bug?

avatar image Bunny83 jmgek · Nov 09, 2015 at 11:22 AM 0
Share

Uhm, how does your question

How can I get the position of a Vertex on a surface?

fit to your comment:

It just returns me the actual vector3 on the surface

I think you should be more clear what you want. Because the question asked for the position (Vector3) in wordspace and in your comment you complain that it just returns the position...

Just to be clear: You talk about a simple $$anonymous$$esh, not a Skinned$$anonymous$$esh like an animated character? Skinning is done dynamically. If you have a skinned mesh you might want to have a look at the relatively new Bake$$anonymous$$esh method which creates a snapshot of the mesh in it's current skinned state.

Anyways you really should clear up your question. Feel free to edit your question and add more information or just be more specific what you actually want and what your setup looks like.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

32 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

Related Questions

Need localPosition.x in world units. 2 Answers

Adjusting localPosition 1 Answer

Help spawning an object relative to the local Z axis of an object 0 Answers

Class member Vector3 based on local transform 1 Answer

How to have an object some distance above another object Locally? 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