1 registered members (AndrewAMD),
1,203
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
check the height of a block
#375185
06/24/11 03:59
06/24/11 03:59
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
is it possible to approach a block, and see if its height (from my players height, to the top of the block) is under a certain number? I have some theories.. but they dont work... basically I have this to start >>
///.. Checked to see if the player is infront of a block
if(trace_hit!=0){
if(you==null){//you are a wall
jump_obstacle=1;
}
}
now since the block is not an entity, the 'you' pointer doesnt work.. so doing this:
///.. Checked to see if the player is infront of a block
if(trace_hit!=0){
if(you==null){//you are a wall
if(vec_dist(my.z, you.max_z)<25){jump_obstacle=1;}
}
}
gives me an empty pointer error any ideas? .. Please Edit: the reason why I would like this is because my player will check to see if the block infront of him is a valid block to jump up onto.. if its higher than 25, he shouldnt jump.. maybe this is some better info?
Last edited by DevoN; 06/24/11 16:52.
|
|
|
Re: check the height of a block
[Re: DLively]
#375331
06/24/11 22:02
06/24/11 22:02
|
Joined: Oct 2009
Posts: 149 Germany
muffel
Member
|
Member
Joined: Oct 2009
Posts: 149
Germany
|
Just an idea: select a point inside the volume near the hit point ( e.g. adding the inverse normal). Now trace upwards. You can check this result for:
the trace hit nothing: it was an outer level wall
the trace hit a backside face: it is a block with a topside check the value wether it has the required height
the trace hit a frontside face: no clue what happens at this point
muffel
Last edited by muffel; 06/24/11 22:04.
|
|
|
Re: check the height of a block
[Re: 3run]
#375355
06/25/11 01:06
06/25/11 01:06
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
K I just can't figure it out!!!!!!!!!! I've been trying every which way to do this and still nothing... the closest thing i can come up with is this: But first, this code checks to see if my player is infront of a block, and if so then turns on the jumping var:
vec_set(checkaheadtemp,vector(5,0,0));
vec_rotate(checkaheadtemp,my.pan);
vec_add(checkaheadtemp,my.x);
trace_mode = ignore_me + ignore_models + ignore_sprites + use_box;
result = trace(my.x,checkaheadtemp);
if(result>0)&&(vec_dist(my.x,links_temp_jump_pos.x)>5)&&(link_on_ground==0){jump_obstacle=1;}
--------------- now this code, is my attempt at figuring this problem out.. but it works in the reverse, So if the block is higher than my players max jumping height, my player jumps..
vec_set(checkaheadtemp,vector(5,0,0));//check in front
vec_rotate(checkaheadtemp,my.pan);//in front of me
vec_add(checkaheadtemp,vector(my.x,my.y,my.z+25));//store my.x to my.z + trace height
trace_mode = ignore_me + ignore_models + ignore_sprites + use_box;
result = trace(vector(my.x,my.y,my.z+25),checkaheadtemp);
if(result>0){
vec_set(checkaheadtemp,vector(5,0,0));
vec_rotate(checkaheadtemp,my.pan);
vec_add(checkaheadtemp,my.x);
trace_mode = ignore_me + ignore_models + ignore_sprites + use_box;
result = trace(my.x,checkaheadtemp);
if(result>0)&&(vec_dist(my.x,links_temp_jump_pos.x)>5)&&(link_on_ground==0){jump_obstacle=1;}
}
any more ideas?
|
|
|
Re: check the height of a block
[Re: DLively]
#375357
06/25/11 01:33
06/25/11 01:33
|
Joined: Apr 2005
Posts: 1,988 Canadian, Eh
DLively
OP
Serious User
|
OP
Serious User
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
|
okay.. I have another idea... but dont know where to go from here. Basically:
vec_set(links_temp_jump_pos, vector(my.x,my.y,my.z+25));
c_trace(my.x,links_temp_jump_pos,ignore_me+ignore_models+ignore_sprites+use_box);
-store the height from link to "above link +25" -then trace between link, and the stored array. now i need to check to see if there is a block somewhere inbetween, otherwise it will just make him jump.. here is an image i made to help me ^_^
|
|
|
Re: check the height of a block
[Re: DLively]
#375366
06/25/11 08:03
06/25/11 08:03
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
No dude, make it like this:
VECTOR end_pos;
vec_set(end_pos,vector(10,0,my.max_z + 10));
vec_rotate(end_pos,my.pan);
vec_add(end_pos,my.x);
c_trace(my.x,end_pos,IGNORE_ME|IGNORE_PASSABLE);
if(trace_hit){/* DON'T JUMP*/}else{/*JUMP*/}
This is not tested, but should give you an idea. This is same as making player climb things, but there you would need second trace from players center.
|
|
|
|