- Home /
Question by
thellama · Oct 18, 2013 at 03:10 AM ·
transformvector3local space
Better way to get relative local vector3?
The below code, gives me a vector3 of (1, 6, 1) in local space around my transform. E.G: when I rotate the transform the vector's position changes as if it was a child.
My question: Is there a better way to do this? I feel like there is a more elegant way than using up 3 lines. It works, obviously, but feels a little clunky.
Vector3 localOffsetVector= (transform.position + transform.right * 1f);
localOffsetVector+= transform.up * 6f;
localOffsetVector+= transform.forward * 1f;
Any thoughts?
Comment
Best Answer
Answer by rutter · Oct 18, 2013 at 03:14 AM
Good instincts. You probably want transform.TransformPoint (or TransformDirection).
Well don't I feel dumb, I tried using transform.InverseTransformPoint but never tried just TransformPoint. Thank you.