Detect collision in server Colyseus (Solved)

Hello everyone,
I'm using Unity for client-side and i want to detect collision in server to anti-hack. How to implement it?

You should use a JS library like Box2dJS:
or detect them yourself like: if distance (ball1,ball2)<ball1.radius+ball2.radius ...
on server side.

@coco thank sir

I do this on my server with no framework (not saying the framework isnt a better option, just wanted to contribute).

Whenever a players x or y is updated i run this function which is inside the player class on the server.

It essentially loops through all the other players in the room, and compares their x and y coordinates to the 1 player who just moved. If the other_players.x is < (player.x-0.4) && other_players.x is < (player.x+0.4) that means they are touching in terms of x axis (my players are about 1 unit wide.

then if other_players.y is < (player.y-0.2) && other_players.y is > (player.y-0.5) that means my player is higher than them at about head level. You would have to play with the values depending on your character size

If both of these are true i run the function to kill them and send that message to all the connected clients where they can vanish the player. I also add them to an array with a timeout so that if they are in that array they cannot be killed again within 2 seconds

Hope this helps someone!