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
12
Question by RoR · Oct 23, 2010 at 02:14 AM · localspaceglobalspace

Explanation Local Vs Global Space

I've read on the documentation and gone through google but my question is in terms of coding, when do I use this?

When do I need to worry about this? Such as if I'm using mouse look script, and i shoot, it dosen't shoot from whre the mouse is looking straight but now it's shooting from the side.

Any advice, thanks.

Also does anyone have a good explanation for local vs global space?

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

4 Replies

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

Answer by Chris Masterton · Oct 23, 2010 at 04:21 AM

I'll try to explain local vs world in 2d and without rotation (because its hard to draw in ascii!)

When we say "this is the position of A in the world" - we are talking about the position of A relative to the world origin. The origin is 0, 0 and where the x & y axis meet. Below shows us A, B & C in WORLD space.

+5          |
+4          A
+3          |      B
+2          |  
+1          |  C
 0 ---------+---------
-1          |
  -9876543210123456789+

Imagine A (0, 4) is an alien, B (7, 3) is a Boss monster and C (3, 1) is our hero - Chris.

When we talk about local space we have to ask - local to what? To translate the world space into Chris' local space we put Chris at the center of the universe. And now in Chris's local space the it looks like.

+4          |
+3       A  |
+2          |   B
+1          |  
 0 ---------C---------
-1          |
  -9876543210123456789+

Long winded way of saying everything is relative - in world space its some arbitrary origin offset. In our local space example the world literally rotates and moves around Chris.

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 arul20 · Oct 23, 2017 at 05:01 AM 0
Share

Such an excellent answer. This should be in the game documentation!

avatar image Ekaitzdev · Feb 16, 2020 at 01:24 PM 0
Share

Your are right all values are relative to another, always. Even to the point of Hardware level! That syncronicity makes the magic of computer systems.

avatar image
5

Answer by Jessy · Oct 23, 2010 at 02:46 AM

There is a button in the upper left of the Editor that lets you switch between the two, in terms of tool handles. Start rotating any object by dragging left and right over X, Y, or Z in the object's Transform component, while making sure the "Move" icon is selected, in the very upper-left of the Editor (it's next to the hand tool). Notice how the tool handles rotate, when you're viewing Local space handles, but stay fixed, when you're viewing Global space handles.

Unity has the concept of "world" space. But every object that you create has its own space, and they very often will not match up. Imagine the way whatever building you live in stays at a "fixed rotation", but you can turn around, within it. So, for example, when you're lying down, your own Y axis is aligned with the "world's" X-Z plane, not its Y axis.

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
4

Answer by rishin458 · Aug 29, 2017 at 10:53 AM

Imagine you're in a car. You have a position and rotation relative to in the car. You're in the driver seat facing out the window. BUT, as the car drives around, and turns, your position on earth is changing, as well as your cardinal facing direction, but your position within the car has not changed.

Same goes with the GameObjects. If you nest a GameObject in another, and then move the parent GameObject around, the child GameObject moves with it. It's local position is that inside its parent, where as the global is its position in the scene. https://forum.unity3d.com/threads/what-is-the-difference-between-local-and-world-coordinates.389439/

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
1

Answer by insoluzioni · Oct 26, 2020 at 10:08 PM

If I may add to such an awesome answer (thank you by the way)... What I was trying to do is determine this local position by converting a 2D collision contact point (from world position to local, of course).

But what I though was that this local position was relative - not only to the targeted transform position - but also to its size... which your answer clarified that it's not.

Couldn't think of how to produce this size relative position until I compared the collider radius with the values I was getting. Turns out that with a collider, its radius can be used to determine that position.

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

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

AddForce in z axis 1 Answer

CharacterControllers and Transform.Rotate 1 Answer

Global and Local(newbie) 1 Answer

How does GetRelativeVector work? 1 Answer

Changing scale of unit 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