- Home /
local axis vs world axis
This is an embarrassingly simple question, but how do I access the the localX axis of a transform vs the world?
I'm using myObject.transform.localPosition.right, but it's clearly still using the world axis when I test. Any clues what I'm doing wrong?
If it helps, I see in the doc description for transform.localPosition: "Position of the transform relative to the parent transform." My object has no parent other than the world itself, so I guess the origin is the parent? Just wanted to mention it in case it helps clarify.
Answer by psantoki · Aug 26, 2014 at 12:49 AM
transform.right
Also useful: transform.up, transform.forward
These will give you the three axes of your object in local space, together can construct an orientation matrix, though you can get that from the transform too.
Good luck my nig nog
Answer by psantoki · Aug 25, 2014 at 11:26 PM
Hi HauntedHotPocket
transform.position
That said, you're actually getting the right answer. If an object has no parent, then its world transform is the same as its local transform.
So keep on keeping on
Re-reading your question, you might be asking about orientation, not position. Let me know
Hmm, then I guess I'm after the wrong thing. When I test and I select my object, then toggle between world and local, I see one transform that remains in the same xyz when I rotate (world), but when I toggle (local) its a transform that updates with the rotation. That's the one I'm trying to access. I'd like to get the transform.position.right, based on where the object is facing.
^ Does this make sense? It might be what you meant about orientation vs position. I'm not sure. Just want to get the x axis based on which way the object is facing.
Is this the button you're toggling?
And is that the position you're looking at?
(Just to be clear)
Yes, that's the one! I'm doing something wrong aren't I?
Your answer
Follow this Question
Related Questions
Head bone rotation question 0 Answers
How to change the position of the Gameobject in 10 second? 1 Answer
Why are my projectiles not following Input.pos after transform movement? 2 Answers
problem with dead space kinesis module system 1 Answer
How can I get an object to orientate behind a plane? 0 Answers