It appears like your "playerBird" game object has no component of type Collider2D
. Make sure that one of the 2D colliders is attached. When you want to find it via GetComponent
, then it must be attached to the object directly. When the collider is attached to a sub-object of the "playerBird", use GetComponentInChildren
instead.
Also keep in mind that there are also colliders which do not have the suffix "2D". These are 3D colliders used by the 3D physics engine. 2D and 3F3D colliders are completely separate systems and do not interact with each other.