Ejemplo n.º 1
0
    public void CheckForSupport(Vector2 forceDirection, bool allowWallRunning)
    {
        RaycastHit2D hit = new RaycastHit2D();

        if (CastLine(Line.Down, Vector2.down, skinwidth, ref hit, DebugData.DebugTag.GroundCast))
        {
            UpdateNormal(hit.normal, forceDirection, allowWallRunning);
            transform.position += (Vector3)(Vector2.down * hit.distance);
            float speedAwayFromNormal = Vector2.Dot(supportNormal, velocity);
            if (speedAwayFromNormal < 0.0f)
            {
                velocity -= supportNormal * speedAwayFromNormal;
            }
            data.AddSupportInfo(new DebugData.SupportInfo()
            {
                supportLocation = hit.point,
                supportNormal   = hit.normal,
            });
        }
        else
        {
            if (supported && !sliding)
            {
                airtimeStart = Time.time;
            }
            supported = false;
        }
    }