Correct usage of body.touching

Hi,

I am struggling with arcade physics and the body.touching functionality. Looking at the examples, it should be simple, however the moment I start using a tween to manipulate the position of the sprite / body rather than leaving it to the arcade physics engine the body.touching functionality stops working. I have put together an example of my own based on an overlap example in the labs:

From my understanding, this should work.

Any ideas?

Thanks in advance!

Tweened bodies often don’t behave as expected because they have zero velocity.

If you want to detect an overlap you can read body.embedded instead of body.touching.*.

For proper collisions you may have to use a custom separation method:

But if possible I would try to tween velocity instead:

3 Likes

Thanks Samme, this has helped a lot!