private float SpeedToNotClipObstacle( Transform entityTransform, DetectCollisionDelegate collisionDelegate, bool flipDirectionOfDelegate, float velocityInCollisionDirection ) { RaycastHit2D obstacleHit = collisionDelegate.DetectCollisionRaycast( entityTransform, flipDirectionOfDelegate ); bool hasHit = GameCorePhysics2D.HasHit(obstacleHit); if (hasHit && obstacleHit.distance < Mathf.Abs(velocityInCollisionDirection)) { return(obstacleHit.distance); } return(velocityInCollisionDirection); }