I’m trying to do ladder in my2Dplatformer and i wanna check if playeris in range of ladder. And it works when he gets in but it doesn’t detect when player goes out of range of ladder and causing enemy to fly.
So here’s part of my code; this LayerMask is set to good layer.
[SerializeField] LayerMask playerLayer;
void Update() {
Collider2D coll = Physics2D.OverlapArea(pointA.transform.position, pointB.transform.position, playerLayer);
if (coll.gameObject != null)
{
// switch on climbing
}
if (coll.gameObject == null)
{
// switch off climbing, this if doesnt work dont matter what i put in
}
}