void DetectClimbable() { // If we're already climbing, return if (isClimbing) { return; } // Otherwise, detect climbable // Perform a box cast that is the size of the player's collision Collider2D[] hits = Physics2D.OverlapBoxAll(transform.position, currentCollider.bounds.size, 0); // Loop through all hits foreach (var hit in hits) { // Check if: if (hit != null && // Something was hit hit.isTrigger) // The hit object is a trigger { // We have found our climbable! climbObject = hit.GetComponent <Climbable>(); return; } } // No Climbables were found climbObject = null; }
void StopClimbing() { climbObject = null; //we are no longer climbing isClimbing = false; //Invoke event if (onClimbChanged != null) { onClimbChanged.Invoke(isClimbing); } //re-enable physics EnablePhysics(); }