• 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 AnthonyMir · Aug 20, 2021 at 07:21 AM · unity 5

Imported 3D OBJ has position and localPosition 0,0,0

i'm importing .Obj and Mtl by script or even by Drag and drop and all the elements inside it are positioned at 0,0,0 but they are placed correctly how can i get correct positioning of the elements ?

This is the following Image(all elements inside the Object are at 0,0,0)

Thank you in advance!

untitled.png (241.6 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 jinoh · Aug 20, 2021 at 10:22 AM 0
Share

please upload your hierarchy and inspecter image

avatar image AnthonyMir jinoh · Aug 20, 2021 at 10:57 AM 0
Share

Done, Thank you in advance

2 Replies

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

Answer by Bunny83 · Aug 20, 2021 at 12:58 PM

how can i get correct positioning of the elements ?

It's not really clear what you mean by that. A mesh / mesh part could be positioned anywhere inside it's local space. So if your "house" consists of several objects, all those objects could use the same local space, so they are all positioned at the same point and all the vertices the parts are composed of are just relative to that. If you want to pivot / origin of the parts to be somewhere else, this has to be done in the modelling software. Unity is not a modelling software.


As a workaround you can put each part into an empty gameobject which you can position at the point where you want the pivot to be and then make the actual piece a child of that. That way you can use that new empty gameobject as the new representation of that piece.


However if it's important to have the pivots at certain points, you have to do that in a modelling software.


I highly recommend you check the settings at the top of your Unity window and set the pivot mode of the editor handles to pivot (not center) and the coordinate space to local (not global)


This way you see where the object really has its pivot. The other modes are just for convenience when it comes to placement in the editor. Though they can mislead you about the actual pivot. As I said, the pivot can not be changed in the Unity editor unless you wrap it in another gameobject. The pivot isn't even a "thing". You can define a rectangle with 4 vertices and have them positioned at:

 (100f, 0f, 0f)
 (100f, 1f, 0f)
 (101f, 1f, 0f)
 (100f, 1f, 0f)

This is a 1x1 rectangle, however it is offset by 100 on the x axis. So it's pivot will be way outside the actual rectangle. That's just how we have defined the vertices here. We can also defined it like this:

 (-0.5f, -0.5f, 0f)
 (-0.5f,  0.5f, 0f)
 ( 0.5f,  0.5f, 0f)
 ( 0.5f, -0.5f, 0f)

This is still a 1x1 rectangle, but this time the pivot is in the center. Again, this is an intrinsic property of how the mesh has been defined. Moving the pivot means you actually have to shift all the vertices by the same amount. In the case of our rectangle, we moved all vertices by (-100.5f, -0.5f, 0f).

Mote modelling tools allow you to do this by just dragging the "pivot" around. I'm not an artist, so don't ask me how to do thing in program X or Y, just google it and I'm sure you find a video explaining it for your favourite modelling tool.

Comment
Add comment · Show 5 · 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 AnthonyMir · Aug 20, 2021 at 01:05 PM 0
Share

@Bunny83 My building is 100% corrent and i don't want to move it i just want to be able to get positions of different objects cause i want to be able to tell the user to tap where he is located in the room, but i'm unable to do that because all objects positions are 0,0,0 globally and locally

do you have a way for me to do that ?

avatar image Bunny83 AnthonyMir · Aug 21, 2021 at 01:52 PM 0
Share

That comment tells me that you either did not read my comment at all, or that you did not understand anything what I said. I don't know what else I should add or which parts I should clarify...


English is not my first language that's why most of my answers are longer than those of most others because I want to make sure I cover everything relevant and that it's clear what I meant. So I'm completely lost now since I don't know which part you haven't understood.


All your parts are located at the same position because that's how those pieces have been designed. I even gave you workaround that you can apply inside Unity by using empty gameobjects are pivots...

avatar image AnthonyMir Bunny83 · Aug 23, 2021 at 06:18 AM 0
Share

@Bunny83 The problem is that i cannot do that i need this process to be automatic the following Elements have pivots in IFC format but the IFC is being converted to .Obj and .Mtl files i think this is where the problem is. after conversion the following elements have the same Coordinates.

and i still can't find a solution for that

Show more comments
avatar image
0

Answer by EliasMiettinen · Aug 20, 2021 at 11:54 AM

Test basic code:

 yourObject.transform.position


This code will return a Vector3.

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 AnthonyMir · Aug 20, 2021 at 12:06 PM 0
Share

@EliasMiettinen this code returns 0,0,0 to all objects i tried it i even tried objectname.transform.localposition , also returns 0,0,0

avatar image EliasMiettinen · Aug 20, 2021 at 12:08 PM 0
Share

Are you objects inside another object?

avatar image AnthonyMir EliasMiettinen · Aug 20, 2021 at 12:12 PM 0
Share

yes @EliasMiettinen, check the above png, also i've tried removing the parent with no result.

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.

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

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

Take a screenshot in realtime then use it immediatly as Texture 1 Answer

Loading GameObject with the Script Attached from the AssetBundle. 0 Answers

TriggerExit not working as intended/Transforming GameObject Problems 0 Answers

I want to ensure that when the slider is activated that the target value is the min value of the slider? 1 Answer

check for click in rhythm game 0 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