Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 tutiplain · Sep 27, 2011 at 06:54 PM · objectcoordinatesspaceplacing

Objects in the same place with different coordinates

Hi,

Since I am not very good at 2d Drawing, I figured I might try to do a "2D" game using 3D. All action happens on the same z coordinate. So I place my player ship on z =-4.9.I then manually move another object to a position where it collides with the player ship. But when I check its z value, it is not the same as the player ship. How can this be? My guess is that the transform.position property is a relative value of some sort.Or am I just seeing things?

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
0
Best Answer

Answer by Rafes · Sep 27, 2011 at 11:10 PM

You are correct in your assumption. This result assumes at least one of your objects has a parent and that the parent is also moved away from the world origin/center.

This goes by different names in different software: Center, origin, pivot... The point from which children and vertices are calculated for an object. An empty game object contains ONLY a transform center, no geometry. This is similar to a locator in Maya or null in Houdini and XSI. When you add geometry, you are basically just adding a bunch of points in this coordinate space with information on how to "connect the dots". This is why geometry moves through 3D space. Because the points are relative to the geometry's transform.

Unity displays this local space in the inspector, which is relative to the parent transform. If one is the child of the scene directly (no GameObject parent) it is in World space. If the other object has a parent, it is relative to that object. If you use the object's transform.position, that is world space, regardless of the parent. transform.localPosition is the same as what you see in the inspector.

This the THE fundamental of 3D work...coordinate spaces....World, local object, even space relative to other objects for calculations. While you rarely need to know the actual math, a basic understanding will allow you to pick the right methods in scripts. Know them, learn them, pretend to love them =)

Comment
Add comment · 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
0

Answer by Piflik · Sep 27, 2011 at 06:58 PM

The coordinates are in relation to the object's pivot, so if the pivot is far off the center, the coordinates are different, even if the objects sit on top of each other.

Comment
Add comment · Show 4 · 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 tutiplain · Sep 27, 2011 at 10:26 PM 0
Share

How can I control the location of an object's pivot, then?

avatar image Piflik · Sep 27, 2011 at 10:39 PM 0
Share

If the objects are created in Unity, the pivots should be centered by default, with other objects you set the pivot in the program in which you created the object. Sometimes the Pivot is set to (0, 0, 0) on export, so you should always place the model on the origin before exporting.

avatar image Rafes · Sep 27, 2011 at 11:11 PM 0
Share

This is a little misleading as you don't want to change the pivot relative to its geometry, which is the method described in the last comment. You want are dealing in transform positions. You just need to change the position to change the position in world space, otherwise, use transform.localPosition, which is relative to the parent.

[I added an answer with more information.]

avatar image aldonaletto · Sep 27, 2011 at 11:12 PM 0
Share

You can't modify the pivot, but you can create an empty object and child your model to it. You can then adjust the Position of your model in the Inspector (it's the position relative to the parent object). Once your model is childed to an object, move this object ins$$anonymous$$d of the model.
But I suspect your problem is of another nature: when moving things in the Scene view, the objects are moved parallel to the screen. If the Scene camera isn't looking directly to the Z direction, any movement will affect the Z coordinate as well. To avoid this, click the Z axis at the Scene Gizmo:

This will ensure the Scene camera is looking to the Z direction, so any movement will only affect the other coordinates.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to find world coordinates within an object? 1 Answer

My jump code seems to be broken, the character's flags for jumping appear to be working strangely. 1 Answer

How to make an object float in space 4 Answers

Diagonal Raycast - Origin problem 1 Answer

Objects local/world cordinate question 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