Mesh/Rigidbody removeChild (applyCentralImpulse)

Software: Away3D 4.x

cdz617, Newbie
Posted: 22 July 2013 09:04 PM   Total Posts: 11

Hello. I’m trying to remove some balls from stage (These balls are thrown like the balls from the awayphysics examples; applyCentralImpulse, etc) but removechild doesn’t seem to work.

What am I doing wrong?

private function onMouseUp1(event MouseEvent3D) : void {
   
                        sphere 
= new Mesh(new SphereGeometry(40),material);

   var 
pos Vector3D = new Vector3D(pPositionX2500, -2000);
   var 
mpos Vector3D = new Vector3D(event.scenePosition.xevent.scenePosition.y+10003900);
  
   
body = new AWPRigidBody(sphereShapesphere18);
   
body.addRay(new Vector3D(), new Vector3D(0,125,0));
   
   var 
impulse Vector3D mpos.subtract(pos);
   
impulse.normalize();
   
impulse.scaleBy(8000);

   
body.position pos;

   
escena.addChild(sphere);
   
   
physicsWorld.addRigidBody(body);


and then

escena.removeChild(sphere);
   
physicsWorld.removeRigidBody(body); 


but the balls keep on the floor…

   

cdz617, Newbie
Posted: 05 August 2013 01:54 PM   Total Posts: 11   [ # 1 ]

could anyone help me please?

or don’t you understand what I’m trying to do?

 

   

John Brookes, Moderator
Posted: 05 August 2013 04:54 PM   Total Posts: 732   [ # 2 ]

escena.removeChild(sphere);
physicsWorld.removeRigidBody(body);

That will remove the last rigidBody and Mesh created.

If you want to remove all the Mesh and rigidbodies.
Store them in a vector or array.
Then loop through them and delete.

Both removeChild and removeRigidbody work ok.

   

cdz617, Newbie
Posted: 07 August 2013 03:26 PM   Total Posts: 11   [ # 3 ]

well, I have uploaded an example.

www.icandoit.es

As you can see, when you shoot many times and then click the red circle, the balls stop because I’ve cleaned up the Physics World, but the only one removed from stage/scene it’s the last one shot. 

I would like to remove all of them at once.


Thank you again.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X