Physics: How to get a bullet to not transfer force to an object it collides with?

Hi All,

I have a bullet object that is set to 0 density. I was expecting that this would give it 0 mass which in turn would mean that it would transfer no force to an object it collides with. Things aren’t working out this way! Whenever my bullet hits a “critter” in my game, it “bumps” that critter.

What do I need to do so that no force/velocity is transferred to the object my bullet hits?

Here is the physics code for my bullet (named “img”… not the best name :frowning: ) set up:
[lua]
physics.addBody( img, “dynamic”, { isBullet = true,
filter = bulletCollisionFilter,
density = 0,
bounce = 0
} )
[/lua]
And here is physics code from a “critter” multi-body object the player might shoot:
[lua]
physics.addBody( critter,
{ friction=0, bounce=0, shape = critterLeft, filter = critterCollisionFilter } ,
{ friction=0, bounce=0, shape = critterRight, filter = critterCollisionFilter } ,
{ friction=0, bounce=.4, shape = critterBottom, filter = critterCollisionFilter }
)
[/lua]
What am I missing?

Thanks :slight_smile:

[import]uid: 105707 topic_id: 35775 reply_id: 335775[/import]

Make the bullet a sensor.

img.isSensor = true [import]uid: 110228 topic_id: 35775 reply_id: 142318[/import]

Thanks for the tip emaurina, that works.

Funny thing is I had tried using the .isSensor property before I had set up any of my collision event listeners so my bullets were flying through everything and I had disabled the property thinking it wasn’t a good approach. Works great now that everything else is implemented :slight_smile:

At some point I would like to experiment with projectiles that ricochet. In this case I would still have the problem I’m encountering. I guess I’m just surprised I’m getting as much “knock back” as I am from an object that has 0 density/mass…

The documentation claims that bodies default density is 1 but when I specify a density of 1 on my img object, the “knock back” is barely detectable as one would expect (just tried this out to see if it would make a difference).

I wonder if bodies do not default to 1 or is there some other issue I’m not aware of? Perhaps multibody objects have a different default?

[import]uid: 105707 topic_id: 35775 reply_id: 142332[/import]

Make the bullet a sensor.

img.isSensor = true [import]uid: 110228 topic_id: 35775 reply_id: 142318[/import]

Thanks for the tip emaurina, that works.

Funny thing is I had tried using the .isSensor property before I had set up any of my collision event listeners so my bullets were flying through everything and I had disabled the property thinking it wasn’t a good approach. Works great now that everything else is implemented :slight_smile:

At some point I would like to experiment with projectiles that ricochet. In this case I would still have the problem I’m encountering. I guess I’m just surprised I’m getting as much “knock back” as I am from an object that has 0 density/mass…

The documentation claims that bodies default density is 1 but when I specify a density of 1 on my img object, the “knock back” is barely detectable as one would expect (just tried this out to see if it would make a difference).

I wonder if bodies do not default to 1 or is there some other issue I’m not aware of? Perhaps multibody objects have a different default?

[import]uid: 105707 topic_id: 35775 reply_id: 142332[/import]