I am trying to understand why I see different coders get a reference to a Rigidbody in two different ways.
One way I have seen is:
public class PlayerController : MonoBehaviour {
Rigidboody rb;
//then in the start or awake function do:
void Awake() {
rb = Getcomponet<Rigidbody>();
}
}
But then I have seen other people doing:
public class PlayerController : MonoBehaviour {
[SerializeField] Rigidboody rb;
void Start() {
}
Then they would drag the Rigidbody component in to the SerializedField in the inspector.
I know both ways work, but what is the difference between them?