Assets/Scripts/Player/Movement/GroundVectorCalculator.cs
/// <summary>
/// casts a ray from location pointed by dir (true for botttomleft, false for bottomright)
/// writes result in angle.
/// </summary>
/// <param name="angle">variable where we store ground vector angle</param>
/// <param name="dir"> location from which we cast ray</param>
casts a ray from location pointed by dir (true for botttomleft, false for bottomright)
writes result in angle.
casts a ray from location pointed by dir ( true for botttomleft false for bottomright ) writes result in angle .
void Cast(ref float angle, bool dir)
            {
                RaycastHit2D hit = Physics2D.Raycast((Vector2)transform.position + new Vector2((dir ? -1 : 1) * 75, 5), -Vector2.up, 500, layerMask);
                if (hit)
                {
                    angle = Vector2.SignedAngle(Vector2.up, hit.normal);
                }
            }
void Cast ( ref float angle , bool dir ) { RaycastHit2D hit = Physics2D . Raycast ( ( Vector2 ) transform . position + new Vector2 ( ( dir ? - 1 : 1 ) * 75 , 5 ) , - Vector2 . up , 500 , layerMask ) ; if ( hit ) { angle = Vector2 . SignedAngle ( Vector2 . up , hit . normal ) ; } }
casts a ray from location pointed by dir (true for botttomleft, false for bottomright)
writes result in angle.
casts a ray from location pointed by dir ( true for botttomleft false for bottomright ) writes result in angle .
// Debug.DrawRay(transform.position + new Vector3((dir ? -1 : 1) * 100, 5, 0), -1000 * Vector3.up);
float
ref
dir
bool
location from which we cast ray
location from which we cast ray
angle
variable where we store ground vector angle
variable where we store ground vector angle