Rigidbody.AddForce with Raycast?

if (Physics.Raycast (transform.position, transform.TransformDirection (Vector3.forward), hit, range)) {
if (hit.collider.attachedRigidbody) {
hit.rigidbody.AddForce (Vector3.forward * force);
}
}
I assumed adding a rigidbody force would take into account the direction the ray was coming from, but I was wrong. I’ve tried Quaternion.identity and transform.localRotation, but the compiler doesn’t understand it. How can I add force to a rigidbody in a forward direction from the point that the rigidbody was hit?

Are you looking for rigidbody.AddForceAtPosition?