Get distance of one axis between two objects
The questions itself its easy:
float distX = obj1.transfrom.position.x - obj2.transform.position.x;
But the problem I have is this one, I want to get the localposition.x relative to the rotation of obj1, so that no matter what is the rotation of obj1 and obj2 it will get the distance in x between the two but relative to Obj1. I cannot use Vector3.Distance() as this will be counting the normalized distance x, y and z, when I only want to get the distance moved on x.
Example:
If interest for more context: I'm trying to make a Runtime position Gizmo, which gets the distance between the gizmo and a Vive controller that had moved away in an axis and add that distance to the position of another object.
Your answer
Follow this Question
Related Questions
Dot Product not equals 1 0 Answers
Object can't get to the target point 0 Answers
Unity 3D C# - Rotation To Slope Of Terrain 0 Answers
OverlapBoxAll rotation 2 Answers