public bool IsLanded()
    {
        AdjustLookDir();
        Visualize();
        var     rot = GlobalFuncs.AroundZero(thisObject.transform.eulerAngles.y) ? 1.0f:-1.0f;
        Vector2 startWithRotation = new Vector2(thisObject.transform.position.x + startPos.x * rot * direction.x, thisObject.transform.position.y + startPos.y);

        return(Physics2D.BoxCast(startWithRotation, boxSize, 0.0f, direction, 0.01f, landLayer));
    }
    public void Visualize()
    {
        var     rot = GlobalFuncs.AroundZero(thisObject.transform.eulerAngles.y) ? 1.0f : -1.0f;
        Vector3 startWithRotation = new Vector2(startPos.x * rot, startPos.y);

        Debug.DrawRay(thisObject.transform.position + startWithRotation - new Vector3(lookDir * boxSize.x / 2, -boxSize.y / 2), lookDir * Vector2.right * boxSize.x, Color.green);
        Debug.DrawRay(thisObject.transform.position + startWithRotation - new Vector3(lookDir * boxSize.x / 2, -boxSize.y / 2), Vector2.down * boxSize.y, Color.green);
        Debug.DrawRay(thisObject.transform.position + startWithRotation + new Vector3(lookDir * boxSize.x / 2, -boxSize.y / 2), lookDir * Vector2.left * boxSize.x, Color.green);
        Debug.DrawRay(thisObject.transform.position + startWithRotation + new Vector3(lookDir * boxSize.x / 2, -boxSize.y / 2), Vector2.up * boxSize.y, Color.green);
    }
Example #3
0
    private void PlayerCheckMove()
    {
        CheckMovementDirection();
        CheckSpeedUp();
        CheckRunInput();
        CheckCrawlInput();
        if (movingDirection != 0)
        {
            if (!BasicHandleHold())
            {
                BasicHandleMove();
            }
        }
        else
        {
            if (!land.landed)
            {
                SlowDown();
            }
            else
            {
                //    var stopInstantly = 1.0f;
                //    move.SlowDown(stopInstantly);
            }
            if (onLadder)
            {
                SlowDown();
            }
        }

        if (!GlobalFuncs.AroundZero(thisObject.velocity.x) || !GlobalFuncs.AroundZero(thisObject.velocity.y))
        {
            anim.SetVar("Moving", true);
        }
        else
        {
            anim.SetVar("Moving", false);
        }
    }
 public void AdjustLookDir()
 {
     lookDir = (GlobalFuncs.AroundZero(thisObject.transform.eulerAngles.y) ? 1.0f : -1.0f);
 }