Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

MMORPG Server From Scratch

Initiate Mage
Joined
Dec 16, 2017
Messages
1
Reaction score
0
Hello,
I've been trying to make an MMORPG of large scale (open-world, PvP, PvE..) with a team of 3 but i'm the only developer. So long i've been using unity3d for the client c# the server, i'm not perfect in programming but i can translate a "solution" into code. Every time i do progress in unity i discover bigger problems. this my architecture for the process.i'm very bad at explaining anything but i will try my best so please bare with me:
Code:
player A requested login.. 
after authentication, 
3d model (character spawned) by a request from the server to spawn that model in a specific location.
another player B logs in,
 there is A is already online so B needs to see A on his screen
 so the server must send B pos of A WITHOUT requesting it 
cuz it should be already saved from move sync class.
 server send pos A to B just before spawning 
then he send B pos of A so A sees B spawned too.
B made a move, 
packet to the server sent with the updated pos of B 
server confirms it (collusion detection) and then sent the updated pos of B to A.
that's how I THINK mmo works so now i'm stuck on sending B pos of A before B spawns. in the server i save last position of the character in a variable, of course its applied to every player. so if there is like 3 already online before the 4th logs in and i need to send the 4th the other 3 players pos how is that possible using 1 variable? like this:
Code:
    //processing packet handler of player movement
.
.
.
//collusion check
if (col != true)
{
   //send back that the pos is confirmed to the client
  // saving that pos in variable
  lastpos = pos;
 // send the updated pos to all other clients
 broadcast(playerid, x,y,z);

}
so when any player moves he goes through this loop and his last pos is saved in lastpos. the 3 already online players goes through this too so there is a lastpos for everyone of them and i need to get it to send it to the 4th so he sees them when he spawn. how can i get it? how can i get every "lastpos" variable of every player there?
 
◝(⁰▿⁰)◜Smile◝ (⁰▿⁰)◜
Developer
Joined
May 29, 2007
Messages
2,167
Reaction score
898
There are many solutions to this problem, one of them is sending snapshots of the game world (positions and important into of all the entities) to the player. As for movement, try to implement movement prediction client-sided, this will help you to avoid desync issues when the player has a high latency with the server.

To put it in simple words:

When a player spawns you basically add them to a grid or to a quadtree, you use that quad tree to notify others inside a certain radius. When the player despawns (teleports, logs-out) then you simply notify the client that the player has been 'removed'.

You send a message to the players that are already logged-in with information of the new player that has just logged in. After you've sent the spawn packet you include the player in the snapshots.

Networking is simply just telling the others what to do. If someone logs in, you tell the others that he/she has logged in. Etc.
 
Upvote 0
Back
Top