x


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?

more ▼

asked Oct 23, 2010 at 02:14 AM

RoR gravatar image

RoR
436 214 174 187

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Oct 23, 2010 at 04:21 AM

Chris Masterton gravatar image

Chris Masterton
564 16 17 36

(comments are locked)
10|3000 characters needed characters left

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.

more ▼

answered Oct 23, 2010 at 02:46 AM

Jessy gravatar image

Jessy
18.3k 208 177 292

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x18
x3

asked: Oct 23, 2010 at 02:14 AM

Seen: 7938 times

Last Updated: Oct 23, 2010 at 02:14 AM