Hidden objects still have physics bodies active

Hi guys

Hoping someone can help me, I have run a few tests and the problem I have is that when I make an object hidden isVisible=false, the object is removed from the screen but its physics body is still active and still registering collisions?

Any ideas please?

Cheers
Dean [import]uid: 75910 topic_id: 36805 reply_id: 336805[/import]

Remove the physics body when you’re not using it, and add the physics body back when you need it again:

physics.removeBody( image );

physics.addBody( image, physicsData );
[import]uid: 145848 topic_id: 36805 reply_id: 145093[/import]

I think a better solution is simply to set the body’s [lua]isBodyActive[/lua] to false (http://docs.coronalabs.com/api/type/Body/isBodyActive.html). This has the effect of removing it from the physics simulation. You would also set the [lua]isVisible[/lua] property to false, as you already have, so that the image associated with the body doesn’t appear on screen.

Hope this helps.

  • Andrew [import]uid: 109711 topic_id: 36805 reply_id: 145095[/import]

Hi

I didnt know about isBodyActive, that’s perfect. Many thanks, much appreciated

Cheers
Dean [import]uid: 75910 topic_id: 36805 reply_id: 145148[/import]

Remove the physics body when you’re not using it, and add the physics body back when you need it again:

physics.removeBody( image );

physics.addBody( image, physicsData );
[import]uid: 145848 topic_id: 36805 reply_id: 145093[/import]

I think a better solution is simply to set the body’s [lua]isBodyActive[/lua] to false (http://docs.coronalabs.com/api/type/Body/isBodyActive.html). This has the effect of removing it from the physics simulation. You would also set the [lua]isVisible[/lua] property to false, as you already have, so that the image associated with the body doesn’t appear on screen.

Hope this helps.

  • Andrew [import]uid: 109711 topic_id: 36805 reply_id: 145095[/import]

Hi

I didnt know about isBodyActive, that’s perfect. Many thanks, much appreciated

Cheers
Dean [import]uid: 75910 topic_id: 36805 reply_id: 145148[/import]

Remove the physics body when you’re not using it, and add the physics body back when you need it again:

physics.removeBody( image );

physics.addBody( image, physicsData );
[import]uid: 145848 topic_id: 36805 reply_id: 145093[/import]

I think a better solution is simply to set the body’s [lua]isBodyActive[/lua] to false (http://docs.coronalabs.com/api/type/Body/isBodyActive.html). This has the effect of removing it from the physics simulation. You would also set the [lua]isVisible[/lua] property to false, as you already have, so that the image associated with the body doesn’t appear on screen.

Hope this helps.

  • Andrew [import]uid: 109711 topic_id: 36805 reply_id: 145095[/import]

Hi

I didnt know about isBodyActive, that’s perfect. Many thanks, much appreciated

Cheers
Dean [import]uid: 75910 topic_id: 36805 reply_id: 145148[/import]

Remove the physics body when you’re not using it, and add the physics body back when you need it again:

physics.removeBody( image );

physics.addBody( image, physicsData );
[import]uid: 145848 topic_id: 36805 reply_id: 145093[/import]

I think a better solution is simply to set the body’s [lua]isBodyActive[/lua] to false (http://docs.coronalabs.com/api/type/Body/isBodyActive.html). This has the effect of removing it from the physics simulation. You would also set the [lua]isVisible[/lua] property to false, as you already have, so that the image associated with the body doesn’t appear on screen.

Hope this helps.

  • Andrew [import]uid: 109711 topic_id: 36805 reply_id: 145095[/import]

Hi

I didnt know about isBodyActive, that’s perfect. Many thanks, much appreciated

Cheers
Dean [import]uid: 75910 topic_id: 36805 reply_id: 145148[/import]