Stop physics objects from pushing one another?

I have several physics objects in my game like, players, bullets etc.

The problem is that when a player touches/pushes another player that another player keeps moving in opposite direction for ever as if i have applied some force to it which goes for ever. The same goes with the bullets, when the bullet collides with the player the player keeps moving in oposite direction forever.

i tried setting the player’s physics property to static, but then i couldn’t move the player using setLinearVelocity.

What is the solution please???

There is such property of physics body as linearDamping. Body doesn’t stop in air because there is no friction. Setting dumping makes object’s velocity to decrease with time.

Hey,

You can either turn off contact between the objects in any pre-collisions using the “event.contact” property.  Check out this: http://www.coronalabs.com/blog/2012/11/27/introducing-physics-event-contact/

But, if you never want them to be able to collide then you’re better off customising which objects can collide with each other and which can’t using filters to define which objects can and can’t collide.  Check out this excellent post: http://developer.coronalabs.com/forum/2010/10/25/collision-filters-helper-chart

Rich

Thank you guys for your suggestions but unfortunately none of them works for me.

I tried linearDumping and it interferred with other behaviors of the character like his movement.

And for event.contact unfortunately i can’t use pre-collision events in my situation.

any options/tricks to disable physics object pushes???

Collison filters? .isSensor property?

Collision filters should definitely work mate.  Maybe you didn’t implement them properly.  As piotrz55 mentioned, isSensor property will work too.

Rich

I am already uising collision filters but players and bullets are supposed to collide with each other.

isSensor made the players to cross each other which i don’t want, i want them to collide with each other but dno’t push each other. Is that possible in Corona???

Thanks Again !!

.isSensor is solution for you. Collision listener will still fire but objects won’t interact physically with each other

Hi @coolromin,

It sounds like your situation is a bit more complex that usual. A few points of advice:

  1. For bullets, probably make them sensors. Or better yet, simply destroy them when they hit a player… that seems logical, unless these are some kind of “plasma beams” that should cut through a player and continue going.

  2. For players not pushing each other around, you could probably detect collision between them and fire off a short (10-30 millisecond) timer that sets them to linear velocity of 0.

Brent

There is such property of physics body as linearDamping. Body doesn’t stop in air because there is no friction. Setting dumping makes object’s velocity to decrease with time.

Hey,

You can either turn off contact between the objects in any pre-collisions using the “event.contact” property.  Check out this: http://www.coronalabs.com/blog/2012/11/27/introducing-physics-event-contact/

But, if you never want them to be able to collide then you’re better off customising which objects can collide with each other and which can’t using filters to define which objects can and can’t collide.  Check out this excellent post: http://developer.coronalabs.com/forum/2010/10/25/collision-filters-helper-chart

Rich

Thank you guys for your suggestions but unfortunately none of them works for me.

I tried linearDumping and it interferred with other behaviors of the character like his movement.

And for event.contact unfortunately i can’t use pre-collision events in my situation.

any options/tricks to disable physics object pushes???

Collison filters? .isSensor property?

Collision filters should definitely work mate.  Maybe you didn’t implement them properly.  As piotrz55 mentioned, isSensor property will work too.

Rich

I am already uising collision filters but players and bullets are supposed to collide with each other.

isSensor made the players to cross each other which i don’t want, i want them to collide with each other but dno’t push each other. Is that possible in Corona???

Thanks Again !!

.isSensor is solution for you. Collision listener will still fire but objects won’t interact physically with each other

Hi @coolromin,

It sounds like your situation is a bit more complex that usual. A few points of advice:

  1. For bullets, probably make them sensors. Or better yet, simply destroy them when they hit a player… that seems logical, unless these are some kind of “plasma beams” that should cut through a player and continue going.

  2. For players not pushing each other around, you could probably detect collision between them and fire off a short (10-30 millisecond) timer that sets them to linear velocity of 0.

Brent