0 registered members (),
18,561
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: ladder detection
[Re: Random]
#312221
02/23/10 19:14
02/23/10 19:14
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
Doesn't work man  Is this from WIKI? And it makes player just walk upwards... to climb... no side walk... no even turning camera... And if make ladder this way, player woun't be able to climb down... Here is my current script made by help of my friend:
function ladder_event()
{
if(you)
{
if(you == player)
{
my.emask &= ~(ENABLE_IMPACT); //prevent the event to be triggered again and again during climbing
wait(1);
while(1)
{
proc_mode = PROC_LATE;
climb = 1;
if(camera.tilt > - 40)
{
ladder_movement.z = 20*(key_w - key_s)*time_step;
}
if(camera.tilt < - 40)
{
ladder_movement.z = 20*(key_s - key_w)*time_step;
}
player_movement.x = 0;
player_movement.y = 0;
c_move(my,ladder_movement,nullvector, IGNORE_PASSABLE | GLIDE );
vec_set(pos1,my.x);
vec_set(pos2,vector(1,0,0));
vec_rotate(pos2,my.pan);
vec_add(pos2,my.x);
vec_set(pos3,vector(0,0,1));
vec_rotate(pos3,my.pan);
vec_add(pos3,my.x);
vec_diff(dir1,pos1,pos2);
vec_diff(dir2,pos2,pos3);
vec_cross(ladder_normal,dir1,dir2);
vec_normalize(ladder_normal,1);
_result = (vec_dot(player.x,ladder_normal)-vec_dot(my.x,ladder_normal))/sqrt( vec_dot(ladder_normal,ladder_normal) );
if(player.z + player.min_z - 30 > my.max_z + my.z || player.z + player.min_z + 20 < my.min_z + my.z || _result < my.min_y || _result > my.max_y || key_space)
{
climb = 0;
break;
}
wait(1);
}
climb = 0;
wait(-0.1); //prevent the player from triggering the event again and again when leaving the ladder
my.emask |= (ENABLE_IMPACT); //make the ladder again sensible for the player
}
}
}
action ladder_act()
{
my.eflags |= FAT | NARROW;
c_setminmax(my);
my.emask |= (ENABLE_IMPACT);
my.event = ladder_event;
}
As you see, I can in my script, here:
vec_set(pos1,my.x);
vec_set(pos2,vector(1,0,0));
vec_rotate(pos2,my.pan);
vec_add(pos2,my.x);
vec_set(pos3,vector(0,0,1));
vec_rotate(pos3,my.pan);
vec_add(pos3,my.x);
vec_diff(dir1,pos1,pos2);
vec_diff(dir2,pos2,pos3);
vec_cross(ladder_normal,dir1,dir2);
vec_normalize(ladder_normal,1);
_result = (vec_dot(player.x,ladder_normal)-vec_dot(my.x,ladder_normal))/sqrt( vec_dot(ladder_normal,ladder_normal) );
if(player.z + player.min_z - 30 > my.max_z + my.z || player.z + player.min_z + 20 < my.min_z + my.z || _result < my.min_y || _result > my.max_y || key_space)
{
climb = 0;
break;
}
I calculate distanse in Y, and save it in _result, so if player walk to the side, if he will be not on ladder, there is a "break" that stopes while loop... now I whant to do the same thing, but only in X coordinates... how to do that? I do not know  please help me.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|