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
1 registered members (TedMar), 1,420 guests, and 3 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
MP problem with camera[SOLVED] #355527
01/27/11 18:17
01/27/11 18:17
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 Guys,

I've got a crash in player_move when a client joins the server.ö do I have to create a new view for every client or what?
Code:
action player_move() // control the player on its client, move it on the server, animate it on all clients
{ 
	VECTOR* cpos;
	my.event = player_remove;
	my.emask |= ENABLE_DISCONNECT;
	my.smask |= NOSEND_FRAME; // don't send animation
	
	var walk_percentage = 0;
	var skill1_old = 0, skill2_old = 0;
	while (1) 
	{
		if (my.client_id == dplay_id)   // player created by this client?
		{
			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);
			vec_set(cpos,my.x);
			cpos.z += 15;
			vec_sub(cpos,camera.x);
			vec_to_angle(camera.pan,cpos);
			if (key_w-key_s != my.skill1) { // forward/backward key state changed?
				my.skill1 = key_w-key_s; 
				send_skill(my.skill1,0); // send the key state in reliable mode
			}
			if (key_a-key_d != my.skill2) { // rotation key changed?
				my.skill2 = key_a-key_d; 
				send_skill(my.skill2,0); // send rotation state in reliable mode
			}
		}

		if (connection & CONNECT_SERVER) // running on the server?
		{
			if (my.skill1 != skill1_old) {    // if movement changed
				send_skill(my.skill1,SEND_ALL); // send movement to all clients
				skill1_old = my.skill1;
			}
			if (my.skill2 != skill2_old) {    // if rotation changed
				send_skill(my.skill2,SEND_ALL); // send rotation to all clients
				skill2_old = my.skill2;
			}
		}

		my.pan += my.skill2*5*time_step;   // rotate the entity using its skill2
		var distance = my.skill1*5*time_step;
		c_move(me, vector(distance,0,0), NULL, GLIDE); // move it using its skill1
		walk_percentage += distance;
		ent_animate(me,"walk",walk_percentage,ANM_CYCLE); // animate the entity


		wait (1);
	}
}



frustrated Liam

Last edited by TheLiam; 01/27/11 18:47.

"Ich weiss nicht genau, was Sie vorhaben, aber Sie können keine Triggerzonen durch Ihr Level kullern lassen."
-JCL, 2011
Re: MP problem with camera [Re: Liamissimo] #355532
01/27/11 18:46
01/27/11 18:46
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Shouldn't
VECTOR* cpos;
be
VECTOR cpos; ?

"do I have to create a new view for every client"
No!

You can use sys_marker to isolate the problem.


"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

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