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 prefix "2D". These are 3d colliders used by the 3d physics engine. 2d and 3d colliders are completely separated systems and do not interact with each other.