Hi,
Ive set up a server/client and a client. The server/client and the client both can shoot bullets. Ive managed to create bullets at the position of the entity/player that is shooting but, i just cant get the bullets to follow the right direction. The direction on the view of the entity that is shooting is correct but, on the view of the other entity the bullet is following a different path. Maybe (just throwing up an idea) i have to send the .pan .tilt etc of the bullet to the entities?
Just to make things a little more clearer:
- There is a server and f.e. 2 clients
- Client1 fires a bullet at client 2
- The bullet is created at the pos of client 1 and travels in the direction client 1 is facing ( the .pan )
- The bullet is created at the position of client1 in the view of client2 but is not follow the right direction.
The code: ( ive only posted the pieces of code that mather imo )
function create_player()
{ enet_ent_create(_str("cbabe.mdl"),creating_pos,_str("move_player"));
}
function move_player()
{
while(enet_ent_globpointer(my) == -1) {wait(1);} //wait until the entity gets a global pointer
players[enet_ent_creator(enet_ent_globpointer(my))] = my; //saves the entity into the players array
cl_id = enet_get_clientid();
on_mouse_left = shootWeapon;
}
function move_bullet()
{
//set(my,INVISIBLE);
while(1)
{
c_move(my, vector(3, 0, 0), nullvector, GLIDE);
wait(1);
}
}
function shootWeapon()
{
ENTITY* bullet;
while(mouse_left == ON)
{
if(players[cl_id] != NULL)
{
vec_set(temp,vector(10,0,29));
vec_rotate(temp,vector(players[cl_id].pan,players[cl_id].tilt,players[cl_id].roll));
vec_add(temp,players[cl_id].x);
bullet = enet_ent_create(_str("Bullet.mdl"),temp,_str("move_bullet"));
bullet.pan = players[cl_id].pan;
bullet.tilt = players[cl_id].tilt;
}
wait(-1);
}
}
I hope some understands my problem and can help me out.
Thanks