i have a problem with updating car tires in my game. there's one action for all four tires and i cant update them properly.

can you please take a look at this code and tell me a way to update, i mean send theirs position correctly?


Click to reveal..

void tire()
{

set(my,SHADOW | CAST);

my.id = wheel_i++ - 1;
wheels[my.id] = my;


while(enet_ent_globpointer(my) == -1) {wait(1);} //wait until the entity gets a global pointer
while(go ==0){wait(1);}

//if(enet_ent_creator(enet_ent_globpointer(my)) == enet_get_clientid()) //if this function runs on the client which created the entity
//{
set_physics(
PH_SPHERE,
PH_SPHERE,
2 + (my.id > 3) * 2,
30,
80,
50,
10,
20,
20
);


printf("");
wheel_ids[my.id] = phcon_add(PH_WHEEL, vehicles[my.id > 3], my);
phcon_setparams1(wheel_ids[my.id], my.x, vector(0, 0, 1), vector(1, 0, 0));
phcon_setparams2(wheel_ids[my.id], vector(
-30 * (my.id == 0 || my.id == 1 || my.id == 4 || my.id == 5),
30 * (my.id == 0 || my.id == 1 || my.id == 4 || my.id == 5),
0), nullvector, vector(spring, damper, 0));

while(enet_get_clientid() > -1)
{
// suspension
ent_animate(vehicles[my.id > 3], (suspensions.pstring)[my.id % 4],
clamp((100.0 / (suspension_max - suspension_min)) * (
(vec_rotate_inverse(vec_diff(my.t1_x, my.x, vehicles[my.id > 3].x), vehicles[my.id > 3].pan)).z
- suspension_min) - 30, 0, 100), ANM_ADD);

phent_getvelocity(my, my.t2_x, nullvector);
vehicles[my.id > 3].speed = (vec_length(my.t2_x) / 32.0) * 60 * 60 / 1000.0;



enet_set_unreliable(1); //send in unreliable mode
enet_send_pos(enet_ent_globpointer(my),-1); //send the new position to all clients

enet_send_angle(enet_ent_globpointer(my),-1);
enet_set_unreliable(0);



wait(1);
}
//}
}



i create tires in this function:

Click to reveal..

function create_player()
{
player=enet_ent_create(_str("aut_f360.mdl"), vector (random(200), random(200), 150), _str("vehicle"));


enet_ent_create (_str("rue_360_d.mdl"), vector (player.x + 17, player.y + 21, player.z - 7), _str("tire")); // FR

enet_ent_create (_str("rue_360_i.mdl"), vector (player.x - 17, player.y + 21, player.z - 7), _str("tire")); // FL

enet_ent_create (_str("rue_360_i.mdl"), vector (player.x - 17, player.y - 33, player.z - 7), _str("tire")); // RL

enet_ent_create (_str("rue_360_d.mdl"), vector (player.x + 17, player.y - 33, player.z - 7), _str("tire")); // RR

}






Last edited by cerberi_croman; 12/06/08 18:09.


Ubi bene, ibi Patria.