Hi there im trying to learn how multiplayer is working i'm reading 3 diffrent tutorials about it but im still stuck at the movement code
I got the connection established the spawn work's the camera works the only thing that doesn't work is the movement :S
Can someone help me a bit with this part ?
And explain me what the code does if you write a code ^^
Thnx allready
Here is my current code.
Code:
// test.wdl
////////////////////////////////////////////////////////////////////////////
// function prototypes
string cbabe_mdl = <Grass.mdl>;
string level_str = <test.WMB>;
////////////SKILLS////////////
define WSpeed, skill2; //Walk Speed
define TSpeed, skill3; //Turn Speed
var move_vec[3]; //Move Speed
//////////////////////////////
// Desc: user controlled player
FUNCTION player_client
{
player = my;
camera.genius = player;
wait(1);
player.skill2 = 5;
player.skill3 = 5;
vec_set(temp, my.x);
temp.z -= 100; // trace downwards 500 quants below
c_trace (my.x,temp,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS|IGNORE_SPRITES|SCAN_TEXTURE);
vec_set(camera.x,vector(player.x,player.y,player.z+50));
vec_set(camera.pan,player.pan);
wait(1);
player_walk();
}
FUNCTION player_walk()
{
move_vec[0] = (key_w - key_s)*MY.WSpeed *time;
if(key_a)
{
my.pan += my.TSpeed*time_step;
}
if(key_d)
{
my.pan -= my.TSpeed*time_step;
}
}
function main()
{
// Create the Cbabe entity on for each Client Session Joining our game world
level_load(level_str);
wait(1);
if (connection & CONNECT_CLIENT)
{
// wait until the level is loaded, and the connection is established
while (connection == 0) { wait(1); }
// create the babe entity at a random place somewhere near the start
temp.X = -6;
temp.Y = -22;
temp.Z = 10;
player = ent_create(cbabe_mdl,temp,player_client);
}
}