Trouble getting players to collide with each other

Posted by gmfk07
I've been mucking about with the Getting Started tutorial, and I modified the code so that obj_player can't go through obj_other_player. However, when I get two players to login and ram into each other, the two objects will get stuck inside each other and not be able to move.

When I recreate the code without GM Server and do it all locally, the objects work as intended - they do not get stuck inside each other. This leads me to believe that it is the lag in GMS that causes the issue; there is a slight discrepancy between where a player object is on someone else's game and where it is on that player's own game, which proves fatal when it comes to these kinds of collisions.

So I ask you, is there any way for me to be able to account for this? Can I make obj_player successfully collide with obj_other_player even when ramming into each other without getting them stuck?

Replies (1)

Last message on 25 Jul 2016

Size43 (Administrator) on 25 Jul 2016, 17:28:23
The lag is a product of the fact that data needs to travel over a network cable, which inherently cannot happen without a propagation delay. There's unfortunately no way around that lag.

What you'd have to do is detect when two player objects get stuck inside eachother, and correct the player's position before handing any collisions. For example, you could move the player back the way it came until it no longer collides with the other player.