Assets/Scripts/Player/Movement/PlayerClipManager.cs
/// <summary>
/// cast rays horizontally and deduce new deltaPositon
/// </summary>
/// <param name="deltaPosition"> reference to original deltaPosition we deduce from</param>
cast rays horizontally and deduce new deltaPositon
cast rays horizontally and deduce new deltaPositon
void HorizontalMove(ref Vector2 deltaPosition)
            {
                int directionX = (int)Mathf.Sign(deltaPosition.x);
                float RayCastLenght = Mathf.Abs(deltaPosition.x);
                Vector2 RayCastOrigin = (directionX > 0 ? PlayerRect.C : PlayerRect.D);
                HorizontalRaySpacing = Mathf.Abs((PlayerRect.B - PlayerRect.C).y) / (HorizontalRayCount - 1);
                for (int i = 0; i < HorizontalRayCount; i++)
                {
                    RaycastHit2D hit = Physics2D.Raycast(RayCastOrigin + HorizontalRaySpacing * i * Vector2.up, directionX * Vector2.right, RayCastLenght, layerMask);
                    if (hit)
                    {
                        deltaPosition.x = directionX * (hit.distance - XW);
                        RayCastLenght = hit.distance;
                    }
                }
            }
void HorizontalMove ( ref Vector2 deltaPosition ) { int directionX = ( int ) Mathf . Sign ( deltaPosition . x ) ; float RayCastLenght = Mathf . Abs ( deltaPosition . x ) ; Vector2 RayCastOrigin = ( directionX > 0 ? PlayerRect . C : PlayerRect . D ) ; HorizontalRaySpacing = Mathf . Abs ( ( PlayerRect . B - PlayerRect . C ) . y ) / ( HorizontalRayCount - 1 ) ; for ( int i = 0 ; i < HorizontalRayCount ; i ++ ) { RaycastHit2D hit = Physics2D . Raycast ( RayCastOrigin + HorizontalRaySpacing * i * Vector2 . up , directionX * Vector2 . right , RayCastLenght , layerMask ) ; if ( hit ) { deltaPosition . x = directionX * ( hit . distance - XW ) ; RayCastLenght = hit . distance ; } } }
cast rays horizontally and deduce new deltaPositon
cast rays horizontally and deduce new deltaPositon
Vector2
ref
<not_specific>
deltaPosition
<not_specific>
reference to original deltaPosition we deduce from
reference to original deltaPosition we deduce from