check the height of a block

Posted By: DLively

check the height of a block - 06/24/11 03:59

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 >>
Code:
///.. 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:
Code:
///.. 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 laugh

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?
Posted By: DLively

Re: check the height of a block - 06/24/11 21:05

I just wanted to bump this, so that it re-appears in the "Newest Posts" menu to the left of the forum, since its been edited.

Hope nobody minds laugh
Posted By: Widi

Re: check the height of a block - 06/24/11 21:13

You don`t can use "you.max_z" if the you pointer is NULL, that gives always a crash!

Use a var to become the distance to the wall:
result = c_trace(my.x, nullvector,IGNORE_ME);
result now have the distance to the wall
Posted By: DLively

Re: check the height of a block - 06/24/11 21:45

yes but I am looking for the height of the wall, not the distance to the wall.
Posted By: Shadow969

Re: check the height of a block - 06/24/11 21:56

easiest way - try tracing from several higher positions, while keeping the same angle. if next trace returns a bigger distance than previous - you found the highest point of the wall. of course this will work only with walls perpendicular to the floor, otherwise you'll have to think of another edge criteria.

so if you trace each 10 quants upwards for example - you can measure the block's height with average accurancy about 5 quants. in your case i'd choose to trace every 5 quants and if 5 traces return the same distance - the wall is 'unclimbable'.

hope that helps.
Posted By: muffel

Re: check the height of a block - 06/24/11 22:02

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
Posted By: 3run

Re: check the height of a block - 06/24/11 22:33

You said that you need to detect walls height for player to jump on it. Just make trace above player's head (if your players height is 25 quants, other way adjust height of the end position for the trace) 10 quant forward, so if it doesn't hit anything jump on it, other ways, don't. I hope it help, good luck.
Posted By: DLively

Re: check the height of a block - 06/25/11 01:06

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:
Code:
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..

Code:
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?
Posted By: DLively

Re: check the height of a block - 06/25/11 01:33

okay..

I have another idea... but dont know where to go from here.

Basically:
Code:
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 ^_^

Posted By: 3run

Re: check the height of a block - 06/25/11 08:03

No dude, make it like this:
Code:
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.
© 2024 lite-C Forums