InverseTransformDirection

I’ve looked at the Unity documentation but I don’t understand what the InverseTransformDirection function does. When normalized, a vector keeps the same direction but its length is 1.0. In the function below, the input variable is equal to the transformed direction from world space to local space, being passed the direction normalized. What does this mean?

public virtual void MoveToPosition(Vector3 targetPosition)
        {
            Vector3 dir = targetPosition - transform.position;
            dir.y = 0;
            //moveDirection = dir.normalized;
            input = transform.InverseTransformDirection(dir.normalized);
            // calculate input smooth
            inputSmooth = Vector3.Lerp(inputSmooth, input, (isStrafing ? strafeSpeed.movementSmooth : freeSpeed.movementSmooth) * Time.deltaTime);
        }

Are you looking at someone else’s code and trying to understand what it means? In that case, transforming the direction from world space to local space means that the vector will be relative to the transform, not relative to the world. For example, imagine you are in bed. Up in world space means the direction towards the sky (or against gravity, if you prefer). Up in your local space is the direction out of the top of your head, probably towards a wall. This allows you to do things like specify that you character should move to their right, not just move to the east (a world-space direction).

Yeah I’m trying to breakdown code line by line and really try and understand not just what it does but why. Thank you for answering the why on this. That was an explanation worthy of an instructor.