Determine in which direction was collision

Hello everybody!
I need to determine in which direction sprite body is colliding with another, but “body.touching” doesn’t work.
What i doing wrong ?

this.physics.add.collider(player, group_pesok, my_collision, null, this);
...............................

function  my_collision( plaay, pesk )
 {

 if (  plaay.body.touching.down == true  )
test_text_2.setText('Touched down!');     
   else 
   test_text_2.setText('Yes! It collided! x = ' + pesk.x + ', y = ' + pesk.y);    
}

Collision itself determines well, when it happens , text display : “Yes! It collided!..” .
But I can not get direction.

Hi, have you tried with console.log instead of setText ? To see what really happens…

I prefer use setText to control processes.
So, no version why it doesn’t work?
If I want make game without gravity ( view from above like pacman ) and i need check collisions between player and walls , what better to use ?
When i remove gravity from config - player and walls become transparent. How to make walls solid ?
Or maybe better use “tiles” for such game ?

Now I figured out that it works only if some gravity set in config ( gravity: { y: 300 }, ):

If I set gravity: { y: 0 } and use setVelocityX , setVelocityY for movement - it works good !

if ( plaay.body.touching.down == true )
test_text_2.setText(‘Touched down!’);

You could do a simple check of your player’s and other body’s x and y to determine collision side. For example, I used such function to check hit from top:

 hitsFromTop(objBody){
return ((this.body.y + this.body.height) <= objBody.y) &&
        (this.body.x - objBody.x > 10 || objBody.x + objBody.width - this.body.x >10) ;

}