Calculate object forward speed ignoring direction

Actually I need to calculate some networked objects to animate correctly, to make that, i need the speed of the object, but with lag the animations dont match, so i want to get the “local” speed of the object.

In my case this object dont have a RigidBody component, the network movement is updating using transform.position, so I dont have speed value to read.

What i want, is calculate the object “forward speed” based on the looking direction, the problem is, the transform. position change between many values when the gameobject move in the word, changing X and Z from positive to negative and back based on look direction (world coordinates).

I dont found a way to get the “moving forward speed” if the player is changing always the coordenates (imagine the player doind a “S” movement always), maybe comparing the previous frame transform.position with the transform.forward and check the % diferences to get the “forward” diference, but dont know…

After some hours of research, I get a working values for forward and lateral movement :

        Vector3 h = transform.right * transform.position.z;
        Vector3 v = transform.forward * transform.position.x;
        Vector3 faceDirection = transform.position + h + v;
        Vector3 direction = faceDirection - transform.position;
        Vector3 moveSpeed = (direction - previousDirection) * 10;

        Debug.Log("Move Speed" + (direction - previousDirection) * 10);

Now with this I get from -1.0 to 1.0 in X for forward and Z for lateral, but have a problem, when the character turn, the values change a lot (all of them), like turn the characters affect all the calculation, and the animations goes mad.