Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Ayumi, ozgur), 678 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Lag in MP (Local) #356231
01/31/11 18:32
01/31/11 18:32
Joined: Jul 2009
Posts: 1,198
Berlin, Germany
L
Liamissimo Offline OP
Serious User
Liamissimo  Offline OP
Serious User
L

Joined: Jul 2009
Posts: 1,198
Berlin, Germany
Hey,

I am sorry to post it here but nobody knew a workaround. MP works so far, but I've got a lag in my local system. I start it as server/client, no lag. Than as client, when I am moving (the player or the camera) it is kinda like jumping around. I thought dplay_smooth could be my fault, but even with 0 it isn't working properly. I post you my code here, but everything should work.

Client has Latency of 9-15 and bps (not moving: 15, moving 70-80), fps are 60 (fps_max is used, otherwise up to 200).
I played around with dplay_smooth/entrate and so on but still laggy.

Code:
Code:
#define speed_y skill1
#define speed_x skill2
#define health skill50

#include <acknex.h>
#include <default.c>
#include <mtlFx.c>
#include <windows.h>

function on_client_event() // terminate client when server disconnects
{ 
	if (event_type == EVENT_LEAVE) sys_exit("Disconnected!"); 
} 

function player_remove() // remove player when client disconnects
{ 
	if (event_type == EVENT_DISCONNECT) ent_remove(me); 
}
action playeract()
{	
	var speed_x_old;
	var speed_y_old;
	var skill3_old;
	my.event = player_remove;
	my.emask |= ENABLE_DISCONNECT;
	my.smask |= NOSEND_FRAME; // don't send animation
	my.health = 100;
	set(my,LIGHT);
	vec_set(my.blue,vector(0,0,255));
	VECTOR verttemp;
	VECTOR cpos;
	VECTOR shoot_there;
	set(my,NARROW|FAT);
	
	wait(1);
	
	c_setminmax(me);
	
	var vspeed_x,vspeed_y,vpan;
	vspeed_x = 0;
	vspeed_y = 0;
	vpan = my.pan;
	while(1)
	{
		if(my.client_id == dplay_id)
		{			
			vpan -= 4 * mouse_force.x;
			my.tilt += 4 * mouse_force.y;
			
			vec_set(cpos,vector(-150,0,50));
			vec_rotate(cpos,vector(my.pan,my.tilt,0));
			vec_add(cpos,my.x);
			vec_set(camera.x,cpos);
			
			vec_set(cpos,vector(0,0,16));
			vec_add(cpos,my.x);
			
			if(c_trace(cpos,camera.x,IGNORE_ME | USE_POLYGON))
			{
				vec_set(camera.x,target);
				vec_add(camera.x,hit.nx);
				vec_add(camera.x,hit.nx);
			}

			vec_set(cpos,my.x);
			cpos.z += 15;
			vec_sub(cpos,camera.x);
			vec_to_angle(camera.pan,cpos);
			my.pan = my.skill3;
			
			accelerate(vspeed_x,(key_w-key_s) * 25 * time_step,0.75);
			accelerate(vspeed_y,(key_a-key_d) * 25 * time_step,0.75);
			
			my.speed_x = vspeed_x;
			my.speed_y = vspeed_y;
			my.skill3 = vpan;
			if(my.speed_y != speed_y_old)
			{
				send_skill(my.speed_y,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
				speed_y_old = my.speed_y;
			}
			if(my.speed_x != speed_x_old)
			{
				send_skill(my.speed_x,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
				speed_x_old = my.speed_x;
			}
			if(my.skill3 != skill3_old)
			{
				send_skill(my.skill3,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
				skill3_old = my.skill3;
			}
		}
		else
		{
			if(connection & CONNECT_SERVER)
			{
				if(my.speed_y != skill1_old)
				{
					send_skill(my.speed_y,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
					skill1_old = my.speed_y;
				}
				if(my.speed_x != speed_x_old)
				{
					send_skill(my.speed_x,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
					speed_x_old = my.speed_x;
				}
				if(my.skill3 != skill3_old)
				{
					send_skill(my.skill3,SEND_ALL|SEND_UNRELIABLE|SEND_RATE);
					skill3_old = my.skill3;
				}
			}
			
			
		}	
		my.pan = my.skill3;
		c_move(me,vector(my.speed_x,my.speed_y,0), nullvector, GLIDE);
		wait(1);
	}
}
function main()
{
	wait(1);
	//sc_setup();
	do { wait(1); }
	while (dplay_status < 2); // wait until the session is opened or joined
	fps_max = 60;
	dplay_entrate = 4;  // 16 ticks/4 = 4 updates per second
	dplay_smooth = 0;
	dplay_localfunction = 2;
	vec_set(sun_pos,nullvector);
	sun_light = 0;
	level_load("teststadium.wmb");
	//sc_hdrRT = 4; 
	// 16/32/64/128 hdr bitdepth
	//sc_hdrBits = 32;
	//turn HDR on/off
	//sc_bHDR = 1;
	if (connection & CONNECT_SERVER) 
	{ // this instance of the game runs on the server
		ent_create ("player.mdl",vector(-256,32,128),playeract); // then create the red guard!
		return;
		
	} 
	else
	{ // Client
		ent_create ("player.mdl",vector(1300,-1296,128),playeract); // create the blue guard
		return;	
	}

}



I deleted not used code, this is all MP code. For better understanding of the "lag" a video from my client:
[video:youtube]http://www.youtube.com/watch?v=2dFvVFGMdcg[/video]

My Internet is very slow but I think that isn't the problem as my test is local and Uureal Tournament 3 is lag free with 32 players.


"Ich weiss nicht genau, was Sie vorhaben, aber Sie können keine Triggerzonen durch Ihr Level kullern lassen."
-JCL, 2011
Re: Lag in MP (Local) [Re: Liamissimo] #356233
01/31/11 18:39
01/31/11 18:39
Joined: Aug 2009
Posts: 1,438
Spain
painkiller Offline
Serious User
painkiller  Offline
Serious User

Joined: Aug 2009
Posts: 1,438
Spain
use nosend parameters and change rotation and position manually


3D Gamestudio A8 Pro
AMD FX 8350 4.00 Ghz
16GB RAM
Gigabyte GeForce GTX 960 4GB
Re: Lag in MP (Local) [Re: painkiller] #356244
01/31/11 20:26
01/31/11 20:26
Joined: Jul 2009
Posts: 1,198
Berlin, Germany
L
Liamissimo Offline OP
Serious User
Liamissimo  Offline OP
Serious User
L

Joined: Jul 2009
Posts: 1,198
Berlin, Germany
Thanks, everything is solved.
Dplay_entrate = 0 wink


"Ich weiss nicht genau, was Sie vorhaben, aber Sie können keine Triggerzonen durch Ihr Level kullern lassen."
-JCL, 2011

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