Question by
OutOfRam · Aug 18, 2016 at 12:35 AM ·
distancelocalrotationlocal axis
Finding distance on a local axis
I need to be able to find the distance between two empties both of which are children of the same gameobject along one axis. however the object is constantly rotating so using worldspace calculations are out. also it needs to be only measured on the one axis sovector3.distance is also out, I just don't know how to get single axis distance on a local axis. any help would be greatly appriciated
Comment
Best Answer
Answer by OutOfRam · Aug 18, 2016 at 06:49 AM
solved it using inverseTransformPoint.
controllerDistance = Mathf.Abs(transform.InverseTransformPoint(controllerPos.position).z - transform.InverseTransformPoint(originPos.position).z)
Your answer
Follow this Question
Related Questions
Movement distance per frame providing choppy values 1 Answer
Move player set distance forward overtime. 0 Answers
Spawn a number of prefabs an equal distance apart 2 Answers
How to use RaycastHit ? 0 Answers
Pixel to z-Distance in Unity 0 Answers