Just Want Collision Detection (No Bouncy, No Rotation)

Hi All,

Physics and Box2D newbie here. I had previously implemented all the physics for a game, myself (movement, boundary detection, etc), but decided to use the physics api for collsion detection ONLY. It works great and successfully determines when one of my display objects collides with another. 

However, the problem I’m facing is that every object I add to the physics begins to stray after some time. Characters that are supposed to remain stationary begin to rotate and display groups begin to separate. I’ve specified 0 gravity, and gave my physics bodies 0 bounce and 1.0 friction (if that matters). Does anyone know what else I need to do?

I should add that most of these physics bodies are display groups, which I remember someone saying is a bad idea, but I don’t think that should really apply here.

Anyway, I really would appreciate some advice from you Corona Elites out there.

– Anthony

tl;dr: Trying to use box2d for collision detection only; I need absolutely no physics interaction aside from the collision detection. 

Hi @antbaca9,

I suppose I’d need to see your implementation, but as you read, adding physics to entire display groups is not advised.

That being said, one way to minimize body rotation is to set the “.isFixedRotation” property on the object. Also, consider giving the objects an absurdly high “density” setting, effectively making them so “heavy” that they will barely move.

Finally, if you follow the above advice and you’re still getting subtle shift over a long period of time, consider the tips outlined in this tutorial:

https://coronalabs.com/blog/2015/03/03/tutorial-solutions-to-common-physics-issues/

Take care,

Brent

 Hi @antbaca9,

 Have you tried setting “object.isSensor = true” ? It will make physics detects collision, but does nothing on it ( no bounce, no rotate ). That’s all I do in my game.

 And more, don’t forget to set gravity to (0,0) to avoid dropping your objects.

 btw, here’s my game :slight_smile:

 https://play.google.com/store/apps/details?id=com.rubycell.game.bunnyjump.wow

If you’re looking to use the bodies as nothing but indicators that a collision has happened, you can fix them in place by setting their body type to static. Setting their isSensor=true will let other objects pass right through, but the began and ended phases will still fire.

If you don’t want to have them as sensors and don’t want to fix them in place with static, you can have an off-screen, static, invisible object which you use as an anchor. This is done by welding the other objects to the anchor which effectively keeps them in place and lets them be dynamic, without the unintended effects of using statics.

Hi @antbaca9,

I suppose I’d need to see your implementation, but as you read, adding physics to entire display groups is not advised.

That being said, one way to minimize body rotation is to set the “.isFixedRotation” property on the object. Also, consider giving the objects an absurdly high “density” setting, effectively making them so “heavy” that they will barely move.

Finally, if you follow the above advice and you’re still getting subtle shift over a long period of time, consider the tips outlined in this tutorial:

https://coronalabs.com/blog/2015/03/03/tutorial-solutions-to-common-physics-issues/

Take care,

Brent

 Hi @antbaca9,

 Have you tried setting “object.isSensor = true” ? It will make physics detects collision, but does nothing on it ( no bounce, no rotate ). That’s all I do in my game.

 And more, don’t forget to set gravity to (0,0) to avoid dropping your objects.

 btw, here’s my game :slight_smile:

 https://play.google.com/store/apps/details?id=com.rubycell.game.bunnyjump.wow

If you’re looking to use the bodies as nothing but indicators that a collision has happened, you can fix them in place by setting their body type to static. Setting their isSensor=true will let other objects pass right through, but the began and ended phases will still fire.

If you don’t want to have them as sensors and don’t want to fix them in place with static, you can have an off-screen, static, invisible object which you use as an anchor. This is done by welding the other objects to the anchor which effectively keeps them in place and lets them be dynamic, without the unintended effects of using statics.