Need help with coordinate conversion.
Hi, I hope you guys can help me out here, I love coming to these forums there's so many answers on here!
I'm having a problem with an IK solution I've wrote, but the problem isn't the IK, the problem is getting coordinates that I need to position things right.
Here's a first bit of code that explains what I'm looking for
 //The originalFootTransform is actually a transform that gets assigned from an instantiated point (at start), thats parented to the players transform 
         //(meaning it is a child immediately under the players transform), and is positioned to the foot.
         //The leftFootTransform is the current (updated every frame) HumanBodyBones transform for the LeftFoot.
         Vector3 relativeLeftFootPos = originalLeftFootTransform.TransformPoint(leftFootTransform.localPosition);
 
         //I need the local x coordinates on the leftFootTransform to be converted 
         //to the coordinates that it would have if it was parented to the same object as the originalLeftFootTransform
         //so that I can determine the distance between the two along the local x axis
         //and I'm finding the distance so I can tell the ik, okay we need to move back to the leftFootIKObj because our feet are to far appart or too close together
         Debug.DrawRay(relativeLeftFootPos, Vector3.up);
 
         //I wanna find the distance between the two on the local x axis
         float distanceXLeftFoot = Mathf.Abs(originalLeftFootTransform.localPosition.x - relativeLeftFootPos.x);
 
         //I got this print going along with the debug ray so I could see all the transfrom conversions visually, but I just cant seem to find one that works
         //I may just be doing to much, it seems like such a simple thing
         print(distanceXLeftFoot);
My Problem
 Vector3 relativeLeftFootPos = originalLeftFootTransform.TransformPoint(leftFootTransform.localPosition);
Like I said in the code sample, I want to convert the LOCAL coordinates of the current left foot transform, to the coordinates that it would be if it was parented to the root parent, so that i can determine the distance between the start position of the foot and the current position of the foot along LOCAL the x axis. I don't know how I could explain it any more detailed, thanks guys.
So in a way I want to convert local coordinates, to local coordinates, so its under the parent objects coordinates. but i wanna convert the left foot (thats is parented under many objects in the root object) coordinates to be relative to our local transform. If that makes any sense :P
Answer by Soloman23 · Mar 01, 2016 at 02:59 PM
Solved this by using transform.InverseTransformVector(leftFootTransform);.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                