Hi,
I’m working on a multiplayer game using P2P but I’m having some issues with creating a player for every game instance and syncing the players’ positions.
Here is everything I already looked at:
- The P2P networking example
- [solved]Sync entity positions over P2P
- Selecting a specific instance of an object + P2P
- [Solved] P2p for more than 2 players
Here is the part of the code that creates the players (ignore the floorchek objects for now):
The idea is to distinguish the players by assinging the client ID to them. (Initially the object variable ID is “n”.) I tried it with 2 players (on 2 separate computers), and while in the client’s game two players were created, in the host’s game there was only one.
But that’s only half of the problem, because when I move the player in the client’s game, the other one moves with it as well, but nothing happens in the host game. And similarly, moving in the host game has no effect on the client.
Here is the code for the controls (again, ignore the floorcheck, I know it’s wrong, but let’s just focus on the left-right movement first):
And after this, I update the position of all players:
I’ve been staring at this for the past week but I just can’t get it to work so any ideas are welcome.