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 valentin-simian · May 08, 2014 at 04:34 AM · meshparticlesystemvertexmeshfilter

How do I get vertex positions of the referenced game object, and not its mesh?

OK, I'm probably missing some terminology but here's what I'm doing:

I've got a script that references a game object which has a mesh. I'm getting the vertex positions of that mesh.

alt text

What I'm getting (the problem):

Unity seems to be referencing the actual mesh, but not the mesh manipulated by the game object.

I'm using this vertex array to as positions to emit particles.

Question:

How do I get the vertex positions of the mesh of the game object?

alt text

Thanks for reading :^)

screen shot 2014-05-07 at 9.31.01 pm.png (33.3 kB)
gettingmesh.jpg (98.5 kB)
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
1

Answer by Eric5h5 · May 08, 2014 at 04:38 AM

My usual technique:

 var thisMatrix = transform.localToWorldMatrix;
 // Get world space for the first vertex in the mesh
 var realPosition = thisMatrix.MultiplyPoint3x4(meshPoints[0]);
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 Eric5h5 · May 08, 2014 at 04:39 AM 0
Share

(You would of course loop through the entire array; the code is just an explanation.)

avatar image valentin-simian · May 08, 2014 at 05:02 AM 0
Share

Thank you.

I've yet to read up on the function you're using, but just using your technique I'm now getting the correct scale of the mesh, but the position is still off.

What is also peculiar is that I'm getting the exact same result as with the solution advised by robertbu below.

edit: actually not peculiar, according to the scripting reference:

$$anonymous$$atrix4x4 localToWorld$$anonymous$$atrix; Description $$anonymous$$atrix that transforms a point from local space into world space (Read Only).

If you're not familiar with using matrices for coordinate transformations, use Transform.TransformPoint ins$$anonymous$$d.

alt text

screen shot 2014-05-07 at 9.59.27 pm.png (16.3 kB)
avatar image
0

Answer by robertbu · May 08, 2014 at 04:37 AM

The vertices in the Mesh.vertices are local coordinates. To convert these vertices to world coordinates, use transform.TransformPoint() on each vertex.

Comment
Add comment · Show 3 · 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 valentin-simian · May 08, 2014 at 05:03 AM 0
Share

Thank you for responding. I don't want to be redundant, but my answer seems to be the same for both you and Eric5h5, so I made my reply there.

avatar image robertbu · May 08, 2014 at 05:37 AM 0
Share

I cannot think of a reason why your position would be off. I've converted mesh vertices to world positions a number of times without issues. $$anonymous$$aybe start by testing your script in a new scene on a simple cube. It also might be something you are doing in your code, so you could add your code to the question.

avatar image valentin-simian · May 08, 2014 at 06:41 PM 0
Share

edit: figured it out — cause of the shifting was Shuriken emitting in local space ins$$anonymous$$d of world.

alt text

screen shot 2014-05-08 at 12.56.37 pm.png (5.8 kB)

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

21 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

Related Questions

Why vertex positions appear (0.0, 0.0, 0.0) ? 1 Answer

Creating a mesh for an overview map 0 Answers

Mesh.vertices are all 0? 1 Answer

Glue GameObject to vertex; 1 Answer

Vertex colours not blending across triangle face 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