Ofxbullet bug BOX drawed

Hi all,
I created a stumbling block for my soccer games.

The stumbling block move from a line in arena like this:

void ofApp::level6() {


	if (!checkLevel6) {

		ostacolo6 = new ofxBulletBox();
		ostacolo6->create(world.world, ofVec3f(xGround - overflow, 0, zGround / 2 ), 0, xOst6, yOst6, zOst6);
		ostacolo6->setProperties(.25, .95);
		ostacolo6->add();

		if (overflow <= xGround && !reverseLevel6) {

			overflow = (overflow + 1);
			cout << overflow << endl;

			if (overflow > xGround) {

				reverseLevel6 = !reverseLevel6;
				cout << reverseLevel6 << endl;
			}

		}

		else if (reverseLevel6) {

			overflow = (overflow - 1);
			cout << overflow << endl;

			if (overflow < 0) {

				reverseLevel6 = !reverseLevel6;

			}
		}

	}


}

In ofApp.cpp i put this code:

	...
			if (levels == 6) {
				
				ostacolo6->draw();
			}
			
			if (levels == 7) {
				ostacolo7->draw();
			}
...

I want only one stumbling block in arena, but the previous stumbling block I cant remove from world. Infact, when levels = 7 I have this problem :

It seems that stumbling block nr°6 is set on world, but not drawed. So the ball impact block n°6.

I try to fix like this:

	if (levels == 6) {
				
		ostacolo6->draw();
	}
			
	if (levels == 7) {
 
		**ostacolo6->remove();**
                ostacolo7->draw();
	}

but there’s error on Visual Studio

Can you help me?

Thank you so much.

@NickHardeman waiting your comment :smiling_face_with_three_hearts:

HI @MikAngelus,

You have to remove it from the bullet world only once. Looks like you are using pointers, so you can do a null check and delete.

if (levels == 6) {
        ostacolo6->draw();
    }
            
    if (levels == 7) {
        if( ostacolo6 != nullptr ) {
            // the remove function is called internally in the deconstructor
            delete ostacolo6;
            ostacolo6 = nullptr;
        }
//        **ostacolo6->remove();**
        ostacolo7->draw();
    }