can I get the physics body properties for the object the player collides with?

How would I get the physics body properties for the object the player collides with?  (e.g. density, bounce etc)

That is within a collision event, e.g.

local function onPlayerCollision(self, event)     local objectHit = event.other     -- How to get physics properties for the "objectHit" end player.collision = onPlayerCollision player:addEventListener( "collision", player )

I’m not the physics expert, but have you tried:

objectHit.density?

objectHit.bounce?

Rob

actually not working in this case - basically my player figure is hitting a ground object tile (using MTE).  So it’s a physics action being triggered (i.e. onPlayerCollision).  Using a “pretty.dump” function I just see the following.  Was just interested in accessing the parameters to help debug…

&nbsp; other = { &nbsp; &nbsp; index = 3, &nbsp; &nbsp; tempScaleY = 32, &nbsp; &nbsp; properties = { &nbsp; &nbsp; &nbsp; physics = "true" &nbsp; &nbsp; }, &nbsp; &nbsp; locX = 12, &nbsp; &nbsp; level = 1, &nbsp; &nbsp; levelPosY = 368, &nbsp; &nbsp; tempScaleX = 32, &nbsp; &nbsp; tile = "2", &nbsp; &nbsp; layer = 4, &nbsp; &nbsp; makeSprite = "function: 0x7fb492b2da60", &nbsp; &nbsp; \_proxy = "userdata: 0x7fb492b2da18", &nbsp; &nbsp; physics = true, &nbsp; &nbsp; levelPosX = 368, &nbsp; &nbsp; tileSet = 1, &nbsp; &nbsp; locY = 12, &nbsp; &nbsp; \_class = { &nbsp; &nbsp; &nbsp; removeEventListener = "function: 0x7fb48afe7ef0", &nbsp; &nbsp; &nbsp; addEventListener = "function: 0x7fb48afe7e90", &nbsp; &nbsp; &nbsp; \_\_index = \<cycle\> &nbsp; &nbsp; } &nbsp; }, &nbsp;

Hi Greg,

I don’t believe these parameters are accessible in this way. I suppose you’d need to set them as properties of the object when you add the body, and then read them during the collision.

Brent

I’m not the physics expert, but have you tried:

objectHit.density?

objectHit.bounce?

Rob

actually not working in this case - basically my player figure is hitting a ground object tile (using MTE).  So it’s a physics action being triggered (i.e. onPlayerCollision).  Using a “pretty.dump” function I just see the following.  Was just interested in accessing the parameters to help debug…

&nbsp; other = { &nbsp; &nbsp; index = 3, &nbsp; &nbsp; tempScaleY = 32, &nbsp; &nbsp; properties = { &nbsp; &nbsp; &nbsp; physics = "true" &nbsp; &nbsp; }, &nbsp; &nbsp; locX = 12, &nbsp; &nbsp; level = 1, &nbsp; &nbsp; levelPosY = 368, &nbsp; &nbsp; tempScaleX = 32, &nbsp; &nbsp; tile = "2", &nbsp; &nbsp; layer = 4, &nbsp; &nbsp; makeSprite = "function: 0x7fb492b2da60", &nbsp; &nbsp; \_proxy = "userdata: 0x7fb492b2da18", &nbsp; &nbsp; physics = true, &nbsp; &nbsp; levelPosX = 368, &nbsp; &nbsp; tileSet = 1, &nbsp; &nbsp; locY = 12, &nbsp; &nbsp; \_class = { &nbsp; &nbsp; &nbsp; removeEventListener = "function: 0x7fb48afe7ef0", &nbsp; &nbsp; &nbsp; addEventListener = "function: 0x7fb48afe7e90", &nbsp; &nbsp; &nbsp; \_\_index = \<cycle\> &nbsp; &nbsp; } &nbsp; }, &nbsp;

Hi Greg,

I don’t believe these parameters are accessible in this way. I suppose you’d need to set them as properties of the object when you add the body, and then read them during the collision.

Brent