Gamestudio Links
Zorro Links
Newest Posts
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
2 registered members (AndrewAMD, Ayumi), 1,395 guests, and 4 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
Page 4 of 5 1 2 3 4 5
Re: [Anet] physics movement setup [Re: darkinferno] #285892
08/21/09 09:31
08/21/09 09:31
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Gumby22don is right it must be 0x00000008 because 0x00000006 is not a power of two (I make this mistake quite often ^^). Btw. the scancodes I used are NOT the scancodes of w-a-s-d!

Best would be to work with the debugger or print the variable.

Test it this way:
- press forward key => see what value skill1 has on the client (1)
- press backward key => check the value (2)
- press left key => check the value (4)
- press right key => ckeck the value (8)

The correct values are in the brackets.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [Anet] physics movement setup [Re: Dark_samurai] #285938
08/21/09 16:39
08/21/09 16:39
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Ok I think I found the problem:

Code:
forward_key = my.skill1&0x00000001; //get bit1
backward_key = (my.skill1&0x00000002)>>1; //bet bit2
left_key = (my.skill1&0x00000004)>>2;
right_key = (my.skill1&0x00000008)>>3;



This should work now.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [Anet] physics movement setup [Re: Dark_samurai] #287580
09/01/09 13:31
09/01/09 13:31
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline OP
Serious User
darkinferno  Offline OP
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
yes it does work, i've been away for a while but in my absence i found several problems with the code setup, this is how i receive the controls on the server:

Code:
if(enet_get_connection() == SERVER_MODE || enet_get_connection() == CLIENT_SERVER_MODE)
	{
		//set up the physic stuff

		
		var forward_key;
		var backward_key;
		var left_key;
		var right_key;
		var space_key;
		
		my.can_jump=0;
		while(1)
		{
			forward_key = my.skill1&0x00000001; //get bit1
			backward_key = (my.skill1&0x00000002)>>1; //get bit2
			left_key = (my.skill1&0x00000004)>>2; //get bit3
			right_key = (my.skill1&0x00000008)>>3; //get bit4
			space_key = (my.skill1&0x000000016)>>4; //get bit5



with the above code setup, i can only move on the server/client not on the normal clients, in order to move on the regular clients i have to add:

" || enet_get_connection() == CLIENT_MODE "

Code:
if(enet_get_connection() == SERVER_MODE || enet_get_connection() == CLIENT_SERVER_MODE || enet_get_connection() == CLIENT_MODE )
	{
		//set up the physic stuff

		
		var forward_key;
		var backward_key;
		var left_key;
		var right_key;
		var space_key;
		
		my.can_jump=0;
		while(1)
		{
			forward_key = my.skill1&0x00000001; //get bit1
			backward_key = (my.skill1&0x00000002)>>1; //get bit2
			left_key = (my.skill1&0x00000004)>>2; //get bit3
			right_key = (my.skill1&0x00000008)>>3; //get bit4
			space_key = (my.skill1&0x000000016)>>4; //get bit5



this allows movement on the client but it also moves the entity directly, meaning that, even if i remove the "enet_send_pos" the model still moves... i really wanna get this basic setup running

Re: [Anet] physics movement setup [Re: darkinferno] #287594
09/01/09 14:36
09/01/09 14:36
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Can you post the whole function and tell me what it exactly should do for you. Then I can tell you where the problem is.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [Anet] physics movement setup [Re: Dark_samurai] #287605
09/01/09 15:19
09/01/09 15:19
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline OP
Serious User
darkinferno  Offline OP
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
Code:
var updateRate;


function control_player()
{
	var oldskill1;
	var save_pan = 0; //stores the entity.pan (needed to find out if the pan has changed)
	
	if(enet_get_connection() == CLIENT_SERVER_MODE) proc_mode = PROC_LATE;
	
	trigger_ctrl();
	
	while(1)
	{
		player_camsys(); //this is cam system of the player, found in player_system.c
		
		//store the keys as bits in a skill1
		my.skill1 = 0;
		my.skill1 |= key_pressed(key_for_str("f")); //forward key in bit0
		my.skill1 |= key_pressed(key_for_str("v"))<<1; //backward key in bit1
		my.skill1 |= key_pressed(key_for_str("c"))<<2; //left key in bit2
		my.skill1 |= key_pressed(key_for_str("b"))<<3; //right key in bit3
		my.skill1 |= key_pressed(key_for_str("Space"))<<4; //right key in bit4

		enet_send_skills(enet_ent_globpointer(my),6,6,SERVER);

		
		if(my.skill1 != oldskill1 && enet_get_connection() != CLIENT_SERVER_MODE) 
		{enet_send_skills(enet_ent_globpointer(my),1,1,SERVER);	oldskill1=my.skill1;} //oldskill1=my.skill1;

		camera.pan -= 2*mouse_force.x; //rotates the entity with the mouse
		camera.tilt += 2*mouse_force.y; //rotates the entity with the mouse
		
		my.pan=camera.pan;
		
		my.skill[2] = camera.pan; //damages the player 
		my.skill[10] = camera.tilt; //damages the player 
		if(save_pan != my.pan) {enet_send_skills(enet_ent_globpointer(my),2,2,-1); save_pan = my.pan;}
		

		enet_send_skills(enet_ent_globpointer(my),10,10,SERVER);

		wait(1);
	}
}

function move_player()
{
	//[UNUSED]var save_pan = 0; //stores the entity.pan (needed to find out if the pan has changed)
	VECTOR save_pos; //stores the entity.pos (needed to find out if the position has changed)
	var timePassed = 0;
	
	while(enet_ent_globpointer(my) == -1) {wait(1);} //wait until the entity gets a global pointer
	
	//pl_animate(1); // this contains the blended animation states
	key_ctrlr(); //controls key inputs
	
	if(enet_ent_creator(enet_ent_globpointer(my)) == enet_get_clientid())
	{ 
		//Every client controls his own player
		control_player();
		control_anim_st();	// this control local animations	
	}
	else
	{
		control_other_anim_st();
	}
	if(enet_get_connection() == SERVER_MODE || enet_get_connection() == CLIENT_SERVER_MODE || enet_get_connection() == CLIENT_MODE )
	{
		//set up the physic stuff
		phent_settype(my, PH_RIGID, PH_BOX);//physik entity definieren & kollision = sphere
		phent_setmass(my, 75, PH_SPHERE);//masse definieren & rotation = sphere
		phent_setdamping(my,100.0, 100.0);//Reibung definieren & drehungsdämpfung nach kollision
		//	phent_setgroup(player, 2);
		
		var forward_key;
		var backward_key;
		var left_key;
		var right_key;
		var space_key;
		
		my.can_jump=0;
		while(1)
		{
			forward_key = my.skill1&0x00000001; //get bit1
			backward_key = (my.skill1&0x00000002)>>1; //get bit2
			left_key = (my.skill1&0x00000004)>>2; //get bit3
			right_key = (my.skill1&0x00000008)>>3; //get bit4
			space_key = (my.skill1&0x000000016)>>4; //get bit5

			phys_ctrl(forward_key,backward_key,left_key,right_key);
			//jump_ctrl(space_key);
			
			if (my.weap_trigger==1)client_shoot();
			
			//sends the position if changed
			if(timePassed >= updateRate)
			{
				vec_set(my.skill[8],my.x);
				enet_send_skills(enet_ent_globpointer(my),8,10,-1); //sends the new skill value
			}
			if(save_pos.x != my.x || save_pos.y != my.y || save_pos.z != my.z) {enet_send_pos(enet_ent_globpointer(my),-1);vec_set(save_pos,my.x);}
			
			//[UNUSED]sends the angles if they changed		
			//[UNUSED]if(save_pan != my.pan) {enet_send_angle(enet_ent_globpointer(my),-1);save_pan = my.pan;}

			timePassed += time_frame;

			wait(1);
		}
	}
	else
	{
		//		my.pan=camera.pan;
		//		my.skill2=my.pan;
		//		enet_send_skills(enet_ent_globpointer(my),2,2,SERVER);
	}

}



basically what i want is for each player to be created as a physics entity on the server[works so far] now i want each client to send the keys pressed to the server, the server then moves that clients' entity and send the positions bac to each client

Re: [Anet] physics movement setup [Re: darkinferno] #287710
09/02/09 09:31
09/02/09 09:31
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Don't do to many steps in one. This is the code how I told you this could be done, right? This should be working this way: The clients send the control input for there players to the server/clientserver. The server/clientserver moves the entity using the physic engine and sends the positions and angles every frame to all the other participants.

Code:
function move_player()
{
	var save_pan = 0; //stores the entity.pan (needed to find out if the pan has changed)
	VECTOR save_pos; //stores the entity.pos (needed to find out if the position has changed)
	
	while(enet_ent_globpointer(my) == -1) {wait(1);} //wait until the entity gets a global pointer
	
	if(enet_ent_creator(enet_ent_globpointer(my)) == enet_get_clientid())
	{ //Every client controls his own player
		control_player();
	}
	if(enet_get_connection() == SERVER_MODE || enet_get_connection() == CLIENT_SERVER_MODE)
	{
		phent_settype(my, PH_RIGID, PH_BOX);//physik entity definieren & kollision = sphere
		phent_setmass(my, 75, PH_SPHERE);//masse definieren & rotation = sphere
		phent_setdamping(my,100.0, 100.0);//Reibung definieren & drehungsdämpfung nach kollision
		//	phent_setgroup(player, 2);
		
		while(1)
		{
			var forward_key = my.skill1&0x00000001; //get bit1
			var backward_key = (my.skill1&0x00000002)>>1; //get bit2
			var left_key = (my.skill1&0x00000004)>>2; //get bit3
			var right_key = (my.skill1&0x00000008)>>3; //get bit4
			var space_key = (my.skill1&0x000000016)>>4; //get bit5

                        phys_ctrl(forward_key,backward_key,left_key,right_key);
			
			
			//sends the position if changed
			if(save_pos.x != my.x || save_pos.y != my.y || save_pos.z != my.z) {enet_send_pos(enet_ent_globpointer(my),-1);vec_set(save_pos,my.x);}
			//sends the angles if they changed
			if(save_pan != my.pan) {enet_send_angle(enet_ent_globpointer(my),-1);save_pan = my.pan;}


			wait(1);
		}
	}

}

function control_player()
{
   if(enet_get_connection() == CLIENT_SERVER_MODE) proc_mode = PROC_LATE;
   while(1)
   {
	vec_set(camera.x,my.x);
	my.skill1 = 0;
	my.skill1 |= key_pressed(key_for_str("f")); //forward key in bit0
	my.skill1 |= key_pressed(key_for_str("v"))<<1; //backward key in bit1
	my.skill1 |= key_pressed(key_for_str("c"))<<2; //left key in bit2
	my.skill1 |= key_pressed(key_for_str("b"))<<3; //right key in bit3
	my.skill1 |= key_pressed(key_for_str("Space"))<<4; //right key in bit4
	if(my.skill1 != oldskill1 && enet_get_connection() != CLIENT_SERVER_MODE) enet_send_skill(enet_ent_globpointer(my),1,1,SERVER);
	wait(1);
   }
}



I will show you how you correctly make a updaterate and interpolation when the code above is working for you and you understood the code.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [Anet] physics movement setup [Re: Dark_samurai] #287725
09/02/09 10:48
09/02/09 10:48
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline OP
Serious User
darkinferno  Offline OP
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
i do have movement but thats just the physics engine, i can walk around using the server/client but the regular clients dont move, i take it they key presses arent being received properly?

Re: [Anet] physics movement setup [Re: darkinferno] #288411
09/05/09 22:27
09/05/09 22:27
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline OP
Serious User
darkinferno  Offline OP
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
i take it this problem is a bit hard to manage?

Re: [Anet] physics movement setup [Re: darkinferno] #288430
09/06/09 09:45
09/06/09 09:45
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Quote:
i take it this problem is a bit hard to manage?


No, this is a simple snippet. Just add me to ICQ (see profil for ICQ number) and I will help you there (this will go much faster).


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [Anet] physics movement setup [Re: Dark_samurai] #288482
09/06/09 19:16
09/06/09 19:16
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
The problem is solved now. I posted final snippet with update_rate and interpolation in the Lite-C Contributions forum.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Page 4 of 5 1 2 3 4 5

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