LibGDX - 碰撞错误(矩形播放器)

LibGDX - Collisions error (player with rectangles)

我认为这是一个简单的错误,但我想了想却崩溃了,我做不到。 我不知道为什么当我和播放器一起跳跃并与另一个矩形(平台)碰撞时,播放器出现在它上面。

        for(RectangleMapObject rectangleObject : map.getLayers().get("platform").getObjects().getByType(RectangleMapObject.class)){

        Rectangle rectangle = rectangleObject.getRectangle();

        float x = rectangle.x;
        float y = rectangle.y;
        float width = rectangle.width;
        float height = rectangle.height;

        shapeRenderer.rect(x, y, width, height);

        //TODO: Finish tile's physics
        if(Intersector.overlaps(rectangle, nihanRect)) {
            if (velocity.y > 0) {
                nihan.getVelocity().y = 0;
                nihan.getPosition().y = y - height - Constants.NIHAN_HEIGHT - 10;


                nihan.setCollisions(false);
                nihan.setAvailableJump(false);
            } else {
                nihan.getPosition().y = y + height - 0.5f;
                nihan.setCollisions(true);

                nihan.setAvailableJump(true);

                if(Gdx.input.isKeyPressed(Input.Keys.Z)){
                    nihan.getPosition().y = y + height;
                }
            }
            nihan.getVelocity().y = 0;

            Gdx.app.log(TAG, "Collision produced!");




        }else{
            nihan.setCollisions(false);

        }}

对不起,如果我的英语不好,我是讲西班牙语的。 您好!

When the player is standing --> After jumping the player appears in the top of the platform

我将变量 "velocity.y" 更改为 "nihan.getVelocity.y"