Getting the correct speed of an object in one direction,Wrong Speed of an Object with ridigbody.velocity.z

Hello,

I have a question on the function:
ridigbody.velocity.z
My maximum speed is around 6.1 in z direction but when my character moves to the left or right there is an increase to around 7~8. I don’t understand how the movement in x and y could have an influence on the z axis as it is perpendicular to it.

With kind regards

I think I also had this problem when I worked on spaceship mechanics. Rigidbody.velocity is a vector in world space but I always thought it would return x,y,z in the rigidbody local direction.

This thread helped me alot.

I looked at the thread you mentioned and I tried the following:

    //SpeedText.text = Player.velocity.z.ToString("0.0");
    SpeedText.text = transform.InverseTransformDirection(Player.velocity).z.ToString("0.0");

But both functions show the exact same number.
Is there Maybe a problem with the following code:

public class PlayerMovement : MonoBehaviour {

public Rigidbody rb;
public float forwardForce = 600f;
public float sidewaysForce = 500f;


// Update is called once per frame
void FixedUpdate ()
{
    rb.AddForce(0, 0, forwardForce * Time.deltaTime);

    if (Input.GetKey("d"))
    {
        rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
    }

    if (Input.GetKey("a"))
    {
        rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
    }

    if(rb.position.y < -1f)
    {
        FindObjectOfType<GameManager>().endGame();
    }
}

}