Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
4 registered members (AndrewAMD, Quad, soulman3, Ayumi), 675 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: some multiplayer thoughts [Re: Superku] #400164
04/26/12 15:01
04/26/12 15:01
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
Thank you man! I got it laugh
But still, there are three strange problems:
* visual rotations are jerking, on the clientside
(on the server side, they rotate but with lag)
* plus there is a problem with X, Y, Z positions of the server:

Originally he was created above the ground, no as on the screen.
On the serverside, everything is ok, this happens only for clients.
* adjusting positions, doesn't seems to work, cause positions are different sometimes.

Here is how I've made script:
Code:
void player_interpolate_move()
{
	VECTOR temp, move_vec;

	proc_kill(5);
	vec_diff(move_vec,my.dplay_x,my.x);
	my.counter = 4;
	while(my.counter > 0)
	{
		vec_set(temp,move_vec);
		vec_normalize(temp,0.25*time_step);
		c_move(my, nullvector, temp, IGNORE_SPRITES | IGNORE_MODELS | IGNORE_WORLD);
		my.counter -= time_step;
		wait(1);
	}
}

void player_interpolate()
{
	if(my.dplay_x || my.dplay_y || my.dplay_z) // you'd better use another skill here like my.dplay_do_interpolation or something like that and reset it after the function call below
	{
		player_interpolate_move();
		vec_set(my.dplay_x,nullvector);
	}
	my.pan += ang(my.dplay_pan-my.pan)*0.5*time_step; 
}

void player_input()
{
	my.keys_x = (key_w - key_s);
	my.keys_y = (key_a - key_d);	
	// change pan here, too
	my.pan -= 0.3 * mickey.x;
}

void player_move()
{
	my.dist_x = 10 * my.keys_x * time_step;
	my.dist_y = 10 * my.keys_y * time_step;
	my.dist_z = 0;
	c_move(my, my.dist_x, nullvector, GLIDE);
	// animate here as well
}

void player_update()
{
	// send keys:
	if(my.keys_x != my.old_keys_x)
	{
		my.old_keys_x = my.keys_x;
		send_skill(my.keys_x, SEND_ALL);
	}
	if(my.keys_y != my.old_keys_y)
	{
		my.old_keys_y = my.keys_y;
		send_skill(my.keys_y, SEND_ALL);
	}
	// send PAN:
	my.pan_update = maxv(my.pan_update - time_step, 0);
	if(!my.pan_update && abs(ang(my.dplay_pan - my.pan)) > 1)
	{
		my.pan_update = 2;
		my.dplay_pan = my.pan;
		send_skill(my.dplay_pan, SEND_ALL); // do not send my.pan here
	}	
	// send positions:
	my.pos_update = maxv(my.pos_update - time_step, 0);
	if(!my.pos_update && vec_dist(my.x, my.dplay_x) > 8)
	{
		vec_set(my.dplay_x, my.x);
		my.pos_update = 8;
		send_skill(my.dplay_x, SEND_ALL | SEND_VEC);
	}
}

action act_player()
{
	wait(1);
	c_setminmax(my);
	
	while(my.client_id < 0) wait(1);

	my.smask |= NOSEND_ALPHA | NOSEND_AMBIENT | NOSEND_ORIGIN | NOSEND_ANGLES | NOSEND_ATTACH | NOSEND_COLOR | NOSEND_FLAGS | NOSEND_FRAME | NOSEND_LIGHT | NOSEND_SCALE | NOSEND_SKIN | NOSEND_SOUND;

	while(1)
	{
		if(my.client_id == dplay_id) player_input();
		else player_interpolate();
		player_move();
		if(my.client_id == dplay_id || connection != 2) player_update();
		wait(1);
	}
}

And here is the download link to give it a try:
download link


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: some multiplayer thoughts [Re: 3run] #400194
04/26/12 22:08
04/26/12 22:08
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Try to use
send_skill_to(NULL,skillXX, SEND_ALL);
instead of
send_skill(skillXX, SEND_ALL); // don't forget SEND_VEC where appropriate
for every send_skill command.

Please be aware that I cannot debug your or someone else's project, I can only give you advice, like Morpheus. There will be a lot more problems like this (and some much uglier) when you develop a multiplayer game.

Btw. try to send the updates on the server only to the clients that do not control the entity (iterate over the clients using client_find, compare their id with ent.client_id and use send_skill_id(...)).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: some multiplayer thoughts [Re: Superku] #400195
04/26/12 22:49
04/26/12 22:49
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
Tried, same result mate, I guess I'm too dumb for multiplayer yet.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: some multiplayer thoughts [Re: Superku] #422284
05/07/13 07:27
05/07/13 07:27
Joined: Jul 2008
Posts: 168
8
82RJZAE Offline
Member
82RJZAE  Offline
Member
8

Joined: Jul 2008
Posts: 168
Just curious: what is the advantage of this system over the native interpolation system?

Also, has anyone managed to fully implement this idea? I'm having a little bit of synchronization problems between the server and client (ie: player location eventually becomes different).

Re: some multiplayer thoughts [Re: 82RJZAE] #422295
05/07/13 09:59
05/07/13 09:59
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The native interpolation system is IMO not very good, highly inflexible and uses too much bandwidth (I would like to be proven wrong if you manage to incorporate it well).

Yes, I have implemented the idea multiple times. Once in a while you need to send the actual position (not only the key input) to avoid an out of sync situation.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: some multiplayer thoughts [Re: Superku] #422353
05/07/13 22:52
05/07/13 22:52
Joined: Jul 2008
Posts: 168
8
82RJZAE Offline
Member
82RJZAE  Offline
Member
8

Joined: Jul 2008
Posts: 168
I'll keep working on it then. What bps rate would you consider too much for Internet play?

Re: some multiplayer thoughts [Re: Superku] #422796
05/17/13 07:04
05/17/13 07:04
Joined: Jul 2008
Posts: 168
8
82RJZAE Offline
Member
82RJZAE  Offline
Member
8

Joined: Jul 2008
Posts: 168
Originally Posted By: Superku
if(my.client_id == dplay_id || connection != 2) player_update();
Why exactly have you set this condition? Won't player_update(); be run on all machines anyways since my.client_id == dplay_id specifies for the client who made the entity and connection != 2 includes the server. In other words, why can't you just remove the if condition?

Likewise, could you clarify what's going on in void player_update()? I still haven't been able to figure out the poor interpolation (leading to synchronization problems) I'm getting when I try to implement this code! The poor synchronization is especially a problem when slowly strafing into a corner leading to another room.

Re: some multiplayer thoughts [Re: 82RJZAE] #422809
05/17/13 11:12
05/17/13 11:12
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I really don't know a guideline for reasonable bps rates, I just try to keep them "as low as possible".


No, this condition is important, consider the following case:

1 server, 3 clients A,B,C, where A is the server (i.e. connection == 3). Now B and C have connection == 2, and one entity on client B's computer is controlled by client C. This entity gets interpolated and receives the updates from the server which itself receives them from client C, who thus both have to execute player_update. However, client B must not send those key and position updates to the server or this would confuse the whole simulation on the server and thus on all other clients.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Page 2 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1