i need a sensor behaviour with a dynamic body

For a game i’m making, i have my character running and encountering enemies.
Whenever he touches an enemy, i need to detect a collision in order apply damage to the character, without the bodies colliding and moving away. The player should run through the enemy while receiving damage. I can resolve this without physics, just by comparing x coordinates.

Now, the problem comes when i want my character to be able to jump ON the enemies, and bouncing over their head. I need to detect the exact moment when the “feet” of the player hit the “head” of the enemy, and then apply an impulse or force to get the bouncing effect.

I can only think of achieving this with collision detection. After detecting a collision between the character and the enemy, if the character’s y coordinates are lower (in value, upper in stage) then he’s on top of the enemy, so he is jumping on it.

Is there a way to get a dynamic body to behave as a sensor while being able to completely collide with other thins?

I need my enemy to collide with the floor and detect collisions with the main character (but not applying any “crash” force after that).

I also don’t believe this can be achieved with collision filters.

I would appreciate a lot any kind of help! [import]uid: 105206 topic_id: 26103 reply_id: 326103[/import]

To detect the character’s feet hitting the enemy’s head - attach a sensor body to the relevant feet and heads using weld joints.

You can make those sensors only detect each other with collision filters, of course, which is probably a good way to go, actually.

Your question:

“Is there a way to get a dynamic body to behave as a sensor while being able to completely collide with other things?”

I would have collision filters setup so that the bodies which you want to have hitting and bouncing off each other actually do. For the other objects you want detecting (‘sensing’) but not bouncing off each other, just attach sensor objects to the regular objects using weld joints, as I said above.

Hmm, that all sounds simple in my head but doesn’t read so well. To simplify:

Create two objects which cannot collide: objects A and B.
Create two objects which can collide but are sensors: AS and BS.
Attach object AS to A and BS to B using weld joints.
Attach your collision handlers as required.
[import]uid: 8271 topic_id: 26103 reply_id: 105707[/import]

I believe that should do it cause it actually makes a lot of sense!
Thank you very much and dont worry, it did sound simple in your words too! [import]uid: 105206 topic_id: 26103 reply_id: 105715[/import]