Want velocity along a direction

How do I get the velocity of my ridgidbody along a certain direction? So I can apply force in that direction if the velocity in that direction isn’t greater than max speed.

Think I solved it.

Vector3 direction;
float directionSpeed;

// you have to reverse the x axis for some reason
Vector3 temp = new Vector3(-rigidbody.velocity.x, rigidbody.velocity.y, rigidbody.velocity.z);
Vector3 rotatedVelocity = Quaternion.LookRotation(direction) * temp;
directionSpeed = rotatedVelocity.z;

Good that it works!

Just wanted to give you this link for the future. This might also make the code’s intent clearer if other people are reading your code.