Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, VoroneTZ, 1 invisible), 1,512 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Kamera in Multiplayer/Cam in Multiplayer #214001
07/01/08 21:56
07/01/08 21:56
Joined: Mar 2008
Posts: 68
Germany, Essen
V
virtualmarctek Offline OP
Junior Member
virtualmarctek  Offline OP
Junior Member
V

Joined: Mar 2008
Posts: 68
Germany, Essen
Deutsch:
Ich möchte eine 1st Person kamera im Multiplayer machen, aber irgendwie funktionierts nicht. Der Code wird ausgeführt, nachdem sich der Player bewegt hat.

English:
I would like to create a 2st person camera in multiplayer, but it doesn work. The code ist started after moving the player.

Code:
function pl_cam()
{
	camera.pan = player.pan;
	camera.tilt = 0;
	camera.roll = 0;
	camera.x = player.x;
	camera.y = player.y;
	camera.z = player.z;
}



mfg, Marc V.
Re: Kamera in Multiplayer/Cam in Multiplayer [Re: virtualmarctek] #214008
07/01/08 23:11
07/01/08 23:11
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
This code shows nothing useful. We need more info on how you start the server/clients.

Last edited by DJBMASTER; 07/01/08 23:12.
Re: Kamera in Multiplayer/Cam in Multiplayer [Re: DJBMASTER] #214038
07/02/08 08:23
07/02/08 08:23
Joined: Mar 2008
Posts: 68
Germany, Essen
V
virtualmarctek Offline OP
Junior Member
virtualmarctek  Offline OP
Junior Member
V

Joined: Mar 2008
Posts: 68
Germany, Essen
Here is the full code:
Code:
#include <acknex.h>
#include <default.c>
#include "status.c"
#include "windows.h"
#include "d3d9.h"


//---------------------------------------------------------------------------------------------||
// some global vars, defines...
//---------------------------------------------------------------------------------------------||
#define force_x skill1
#define force_y skill2
#define force_z skill3
#define force_pan skill4
#define MAX_CONNECTIONS 8

VECTOR camVel;
var force[3];
var vecFrom[3];
var vecTo[3];


//---------------------------------------------------------------------------------------------||
// function prototypes
//---------------------------------------------------------------------------------------------||
void playerAct();
void inputs();
void server_called();
void client_called();
void donothing(){wait(1);}


//---------------------------------------------------------------------------------------------||
// main function
//---------------------------------------------------------------------------------------------||
int main()
{
	video_mode = 8;
	video_depth = 32;
	video_screen = 2;
	fps_max = 60; // lock fps at 60 for all players
	fps_lock = ON;
	dplay_smooth = 0; // dplay_smooth is causing too much overshoot and jerks
	
	on_server = server_called; // on server event, call server_called()
   on_esc = donothing;
   
   wait(-.3);
   if(connection == 3){
   	people_connected = 1;
   	str_cpy(messages_str, "Connecting as a HOST...");
   	wait(-3);
   	reset(messages_txt, VISIBLE);
   	set(connected, VISIBLE);
   	set(status, VISIBLE);
   	video_window(NULL,NULL,16,"HOST...");
   }
   if(connection == 2){
   	str_cpy(messages_str, "Connecting as a CLIENT...");
   	wait(-3);
   	reset(messages_txt, VISIBLE);
   	set(connected, VISIBLE);
   	set(status, VISIBLE);
   	video_window(NULL,NULL,16,"CLIENT...");
	}

   level_load("test.wmb");
   wait(-.3);
   player = ent_create("aim.mdl", vector(0,0,100), playerAct);
   
   wait(-.3);
   
   inputs();
   
    
   while(1)
	{
		again:
		// constantly checks if server is still online
		if(dplay_bps == 0 && dplay_latency == 0 && connection == 2)	{
			if (MessageBox(NULL, "Server is offline and the game will shutdown.", "Error", MB_OK | MB_ICONSTOP) == IDOK){
				sys_exit(NULL);
			}
		}
		if(key_esc){
			while(key_esc){wait(1);}
			if(MessageBox(NULL, "Do you really want to quit?", "Quit?", MB_YESNO | MB_ICONQUESTION) == IDYES){sys_exit(NULL);}
				else{wait(1);goto again;}
		}
		wait(1);
	}
}


//---------------------------------------------------------------------------------------------||
// function for handling inputs
//---------------------------------------------------------------------------------------------||
void inputs()
{
	while(1){
		player.force_x = (key_w - key_s) * time_step * 15;
		player.force_y = (key_a - key_d) * time_step * 15;
		player.force_pan -= mouse_force.x * 15 * time_step;
		
		if(connection == 2){
			send_skill(player.force_x, SEND_VEC);
			send_skill(player.force_pan, 0);
		}
		
		wait(1);
	}
}


//---------------------------------------------------------------------------------------------||
// Kamera Funktion
//---------------------------------------------------------------------------------------------||
function pl_cam()
{
	camera.pan = player.pan;
	camera.tilt = 0;
	camera.roll = 0;
	camera.x = player.x;
	camera.y = player.y;
	camera.z = player.z;
}


//---------------------------------------------------------------------------------------------||
// move player function
//---------------------------------------------------------------------------------------------||
void movePl()
{
	while(1){
		my.pan = my.force_pan;
	
		force[0] = my.force_x * 15 * time_step;
		force[1] = my.force_y * 10 * time_step;
		force[2] = 0;
		
		move_mode = GLIDE|IGNORE_PASSABLE|IGNORE_PASSENTS|IGNORE_YOU;
		c_move(my, force, nullvector,move_mode);
		
		if (my.force_x || my.force_y || my.force_z)
		{
			trace_mode = IGNORE_SPRITES|IGNORE_PASSENTS|IGNORE_PASSABLE|IGNORE_MODELS|USE_BOX;
			vec_set(vecFrom,my.x);
			vec_set(vecTo,my.x);
			vecTo[2] -= 400;
			result = c_trace(vecFrom,vecTo,trace_mode);
			my.z = target.z + ((my.max_z - my.min_z)/2);//Set to the floor
		}
		pl_cam();
		wait(1);
	}
}


//---------------------------------------------------------------------------------------------||
// player action
//---------------------------------------------------------------------------------------------||
action playerAct()
{
	my.emask |= ENABLE_DISCONNECT;
	my.smask |= NOSEND_FRAME;
	
	c_setminmax(my);
	
	wait(-.3);
	ent_sendnow(my);
	wait(-.3);

	set(me, SHADOW);
	movePl();
}


//---------------------------------------------------------------------------------------------||
// function Server_Called(): server was called
//---------------------------------------------------------------------------------------------||
void server_called()
{
	if ((event_type == EVENT_JOIN) && (people_connected < MAX_CONNECTIONS))
	{
		people_connected += 1; // another person connected
		send_var(people_connected); // send number of people connected
	}
	if (event_type == EVENT_LEAVE)
	{
		people_connected -= 1; // one less person connected to server
		send_var(people_connected); // send number of people connected
	}
}


//--------------------------------------------------------------------
// player events
//--------------------------------------------------------------------
void player_events()
{
	if (event_type == EVENT_DISCONNECT)
	{
		ent_remove(me); // remove ent of player that quit
	}
}


There is no Host (-sv -cl) only a Server (-sv) and a Client (-cl)

Last edited by virtualmarctek; 07/02/08 08:25.

mfg, Marc V.
Re: Kamera in Multiplayer/Cam in Multiplayer [Re: virtualmarctek] #214039
07/02/08 08:29
07/02/08 08:29
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
ooh, that's my code smile put pl_cam(); under inputs(); in main function and add inside pl_cam function while loop...i'm not sure if that'll work but try it...



Ubi bene, ibi Patria.
Re: Kamera in Multiplayer/Cam in Multiplayer [Re: croman] #214042
07/02/08 08:39
07/02/08 08:39
Joined: Mar 2008
Posts: 68
Germany, Essen
V
virtualmarctek Offline OP
Junior Member
virtualmarctek  Offline OP
Junior Member
V

Joined: Mar 2008
Posts: 68
Germany, Essen
yes its your code, becaus I read it and i understand it. Its not so big like Locoweeds code wink

And now my result:
It works, I just have to make the camera higher, but thats no problem, because the cam is on the roof.


mfg, Marc V.
Re: Kamera in Multiplayer/Cam in Multiplayer [Re: virtualmarctek] #214043
07/02/08 08:43
07/02/08 08:43
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
so...this what i told you is working? does it work on client too?



Ubi bene, ibi Patria.
Re: Kamera in Multiplayer/Cam in Multiplayer [Re: croman] #214044
07/02/08 09:01
07/02/08 09:01
Joined: Mar 2008
Posts: 68
Germany, Essen
V
virtualmarctek Offline OP
Junior Member
virtualmarctek  Offline OP
Junior Member
V

Joined: Mar 2008
Posts: 68
Germany, Essen
i have only a client and a server no host!


mfg, Marc V.
Re: Kamera in Multiplayer/Cam in Multiplayer [Re: virtualmarctek] #214334
07/04/08 08:02
07/04/08 08:02
Joined: Mar 2008
Posts: 68
Germany, Essen
V
virtualmarctek Offline OP
Junior Member
virtualmarctek  Offline OP
Junior Member
V

Joined: Mar 2008
Posts: 68
Germany, Essen
Now there is a problem with the 3rd Person Camera. While I turn around the cam I see the player more times for short.

Here's my code:
Code:
//---------------------------------------------------------------------------------------------||
// 3rd Person Kamera Funktion
//---------------------------------------------------------------------------------------------||
var pan1;
var pan2;

void pl_cam()
{
	while(1) {
		pan1=cos(camera.pan)*300;
		pan2=sin(camera.pan)*300;
		camera.pan = player.pan;
		camera.x = player.x-pan1;
		camera.y = player.y-pan2;
		camera.z = player.z + 80;
		wait(1);
	}
}



mfg, Marc V.
Re: Kamera in Multiplayer/Cam in Multiplayer [Re: virtualmarctek] #214345
07/04/08 09:22
07/04/08 09:22
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
well...again, that problem you caused, no offens. something's wrong with your camera or/and with your player turning left,right... post here part of your code where the player is paning and where you call camera function



Ubi bene, ibi Patria.
Re: Kamera in Multiplayer/Cam in Multiplayer [Re: croman] #214346
07/04/08 09:23
07/04/08 09:23
Joined: Mar 2008
Posts: 68
Germany, Essen
V
virtualmarctek Offline OP
Junior Member
virtualmarctek  Offline OP
Junior Member
V

Joined: Mar 2008
Posts: 68
Germany, Essen
its the same with the 1st person camera only the cameracode is changed form 1st person in 3rd person!


mfg, Marc V.
Page 1 of 3 1 2 3

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