GetComponent<T>() gets a component from the same GameObject.
Rigidbody rb = GetComponent<Rigidbody>();
Store references instead of searching every frame:
private Rigidbody rb;
void Awake()
{
rb = GetComponent<Rigidbody>();
}
Safer lookup:
if (TryGetComponent<Rigidbody>(out Rigidbody rb))
{
}
Related methods:
GetComponentInChildren<T>()
GetComponentInParent<T>()
GetComponents<T>()