Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (howardR, 7th_zorro), 893 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 5 1 2 3 4 5
Re: [Anet] physics movement setup [Re: darkinferno] #285687
08/19/09 17:15
08/19/09 17:15
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 your code? (the entity function)


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] #285703
08/19/09 18:32
08/19/09 18:32
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:
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
		while(1)
		{
			vec_set(camera.x,my.x);
			//store the keys as bits in a skill1
			// if(my.skill1 != oldskill1) enet_send_skill(enet_ent_globpointer(my),1,1,SERVER);
			wait(1);
		}
	}
	if(enet_get_connection() == SERVER_MODE || enet_get_connection() == CLIENT_SERVER_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
		
		while(1)
		{
			//use skill1 for the controls of the entity
			
			
			//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);
		}
	}

}



thats it so far

Re: [Anet] physics movement setup [Re: darkinferno] #285717
08/19/09 19:10
08/19/09 19:10
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Yeah so what's the problem? Now you have to save every key that is used for the controls as a seperate bit in skill1.

And on the server you evaluate the input and do the movement.

Then the snippet is ready.


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] #285721
08/19/09 19:19
08/19/09 19: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)
yes, am not worried about that, what am saying is, with the above code, when i run as server/client, the client that comes with that option isnt receiving any position updates... so when i start a game with server/client:

the character floats there, when i join as another client, i fall to the floor, as i should, all clients see the server/client floating in the air, position isnt being updated, dont know if i'm being clear

Re: [Anet] physics movement setup [Re: darkinferno] #285726
08/19/09 19:32
08/19/09 19:32
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Oh you meand that. Yes currently the code is designed that only normal clients can control players.

The problem is the if construction. When the client server runs this function and it created the entity the execution of the function get's stuck in the first while loop.

This could should also make it able for the client server to control players:

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)
	{
		//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
		
		while(1)
		{
			//use skill1 for the controls of the entity
			
			
			//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);
	//store the keys as bits in a skill1
	// if(my.skill1 != oldskill1 && enet_get_connection() != CLIENT_SERVER_MODE) enet_send_skill(enet_ent_globpointer(my),1,1,SERVER);
	wait(1);
   }
}



Please notice the change in the if(my.skill1 != oldskill ... line. If you are controling your player as client server there is no need to send the skill. Also the PROC_LATE is important, otherwise the movement will lag a bit (see manual for PROC_LATE).


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] #285749
08/19/09 20:51
08/19/09 20:51
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 works perfectly, i was looking into how to store the key pressed into a skill, was looking at key_lastpressed but i dont think it'll accomplish what i'm trying to do, i take it i have to be sending the scan code of the keys but basically am on my way now ^^

Re: [Anet] physics movement setup [Re: darkinferno] #285798
08/20/09 08:46
08/20/09 08:46
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
I meant it this way:

Every key can be pressed or not pressed => 1 or 0
A skill consists of 4 Byte => 32 bit

Now you say, bit 1 is the status of the move forward key. If bit1 is 1 this key is pressed, if it is 0 it isn't.

This is how you store the keys:
Code:
my.skill1 = 0;
my.skill1 |= key_pressed(20); //forward key in bit1
my.skill1 |= key_pressed(21)<<1; //backward key in bit2
my.skill1 |= key_pressed(22)<<2; //left key in bit3
my.skill1 |= key_pressed(23)<<3; //right key in bit4
//and so on



On the server you can get them this way:
Code:
forward_key = my.skill1&0x00000001; //get bit1
backward_key = my.skill1&0x00000002; //bet bit2
left_key = my.skill1&0x00000004;
right_key = my.skill1&0x00000006;
//and so on




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] #285866
08/20/09 20:38
08/20/09 20:38
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)
it seems ok, but i'm using it in the same way you gave:

but on the server i can only get the forward key, everything else is non-responsive, am i missing something, also, is there anything like this anywhere in the manual

Re: [Anet] physics movement setup [Re: darkinferno] #285871
08/20/09 21:58
08/20/09 21:58
Joined: Oct 2006
Posts: 175
G
Gumby22don Offline
Member
Gumby22don  Offline
Member
G

Joined: Oct 2006
Posts: 175
I'm no expert, but should:

right_key = my.skill1&0x00000006;

be

right_key = my.skill1&0x00000008;

Just for someone trying to grab all this code, as a beginner it may be confusing. (Reason, powers of two are used to store these numbers on top of each other like this)

-Don
have a great day

Re: [Anet] physics movement setup [Re: Gumby22don] #285873
08/20/09 22:50
08/20/09 22:50
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 i see, this isn't the problem however, the problem is, it doesn't seem to be storing the values correctly, i store the values in the exact same way as dark_samurai stated but only the first one seems to work, which is:

my.skill1 = 0;
my.skill1 |= key_pressed(20); //forward key in bit1

i then get that value and store it in a variable called forward_key
forward_key = my.skill1&0x00000001; //get bit1

this works and i am able to get forward movement on the server, i get no other movement however so am wondering if the values are being stored correctly..

Page 3 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