コード例 #1
0
    void FixedUpdate()
    {
        if (endGame || paused)
        {
            return;
        }
        GetComponent <Rigidbody2D>().AddForce(new Vector2(((input.x * speed) - GetComponent <Rigidbody2D>().velocity.x) * (groundState.onGround() ? accel : airAccel), 0));
        GetComponent <Rigidbody2D>().velocity = new Vector2((input.x == 0 && groundState.onGround()) ? 0 : GetComponent <Rigidbody2D>().velocity.x, (input.y == 1 && groundState.isTouching()) ? jump : GetComponent <Rigidbody2D>().velocity.y);

        if (groundState.onWall() && !groundState.onGround() && input.y == 1)
        {
            GetComponent <Rigidbody2D>().velocity = new Vector2(-groundState.getWallDir() * speed * 0.75f, GetComponent <Rigidbody2D>().velocity.y);
        }

        input.y = 0;
    }