ladder detection

Posted By: 3run

ladder detection - 02/21/10 11:19

Is there any way to make player leave ladder, if he for example turn away from it while climbing... or walks to sides or backwards? I tryed to use c_trace... but some problems with it, if player reaches the top of the ladder, trace is not touching it... so player just falls down...
Posted By: 3run

Re: ladder detection - 02/21/10 12:40

Any one frown Really need help here
Posted By: Superku

Re: ladder detection - 02/21/10 14:18

Originally Posted By: 3run
Today at 01:19 PM

Originally Posted By: 3run
Today at 02:40 PM


Do you notice something?

And another thing:

Version 1) : My cake tastes bad. What have I done wrong?

Version 2) : I have used the following ingredients to make a cake: LIST. The cake tastes too sweet. What should I improve?
Posted By: mikaldinho

Re: ladder detection - 02/21/10 14:22

i dont understand what you just said?
Posted By: Superku

Re: ladder detection - 02/21/10 14:37

This does not surprise me at all !!
Posted By: mikaldinho

Re: ladder detection - 02/21/10 14:39

Originally Posted By: Superku
This does not surprise me at all !!


what do you mean?
Posted By: 3run

Re: ladder detection - 02/21/10 15:39

Superku you need my script?! If so, I can post it here, that is not problem.
Posted By: 3run

Re: ladder detection - 02/21/10 18:18

Will some one try to help me? frown
Posted By: TheThinker

Re: ladder detection - 02/21/10 22:18

So,
Here my tip.
Use a passable area (block/ model) like water. If you touch it, you can move in every direction. This is very easy to implement. But you need to know the event system of Lite-C.
If you are inside this area you have to check the content var of c_move and the type of the touching model.
But don't expect, that I write such a code for you.

Perhaps you can SHOW YOUR code, than we are able to help you.

MfG,
Patrick
Posted By: 3run

Re: ladder detection - 02/21/10 22:47

HERE IS MY SCRIPT:

Code:
var climb = 0;
var allow_climb = 0;
var ladder_movement[3];
var ladder_normal[3];
var _result;
var dir1[3];
var dir2[3];
var pos1[3];
var pos2[3];
var pos3[3];
var trace_coords;

function ladder_event()
{
	if(you)
	{
		if(you == player)
		{
			my.enable_impact = off;	//prevent the event to be triggered again and again during climbing
			vec_set(my.skill21,player.x);	//store the players position
			while(1)
			{
				proc_late();
				climb = 1;
				vec_set(player.x,my.skill21);	//place it at the stored position to prevent the normal movement
				my.skill30 = c_move(player,ladder_movement,nullvector,ignore_passable|ignore_passents|glide);	//move the player up or down
				if(camera.tilt > - 40)
				{
					ladder_movement.z = 25 * (key_w - key_s)*time_step;
			   } 
			   if(camera.tilt < - 40)
			   {
			   	ladder_movement.z = 25 * (key_s - key_w)*time_step;
			   }
			   ladder_movement.x = 0;
			   ladder_movement.y = 25*(key_a - key_d)*time_step;
			   
			   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) );
			   
			   vec_set(trace_coords.x, vector(400, 0, 0)); 
			   vec_rotate(trace_coords.x, player.pan);
			   vec_add(trace_coords.x, player.x);
			   
			   c_trace(player.x, trace_coords.x, IGNORE_ME | GLIDE); 
			   if(trace_hit){allow_climb = 1;}else{allow_climb = 0;}
			   if(allow_climb == 0 || _result < my.min_y || _result > my.max_y || key_space == 1)	
				{
					climb = 0;
					break;	
				}
				vec_set(my.skill21,player.x);	
				
				wait(1);
			}
			climb = 0;
			wait(-0.1);	
			my.enable_impact = on;	
		}
	}
}

action ladder()
{
	my.enable_impact = on;
	my.event = ladder_event;
	my.polygon = on;
	c_setminmax(me);
}


But as I sad, not that good...is there any way to make trace wider?? please help...
Posted By: 3run

Re: ladder detection - 02/22/10 11:07

Damn! Will some one try to help?! I even posted my script!!!!!!
Posted By: Superku

Re: ladder detection - 02/22/10 14:59

Ask yourself a question:
Do you want to have a finished game or do you want to create your own game?
In the latter case try and learn by yourself (asking is of course allowed but should not be the primary option).

And never say something like "Damn! Will some one try to help?! I even posted my script!!!!!!" again or I will punch your healthpoints out of you.
Posted By: 3run

Re: ladder detection - 02/22/10 17:07

Damn! Will some one try to help?! I even posted my script!!!!!!
Now try to punch my healthpoints out of me, if you can badass! grin And I'm not asking for finished game, the ladder script is the only thing left undone in my player script laugh All I'm asking is some ideas how to creat ladder as I sad. Or batter for example of script or even small demo.
Posted By: Superku

Re: ladder detection - 02/22/10 17:15

Try to change the bold line

proc_late();
climb = 1;
vec_set(player.x,my.skill21); //place it at the stored position to prevent the normal movement
my.skill30 = c_move(p...

into player.z = my.skill23;



and

break;
}
vec_set(my.skill21,player.x);
wait(1);

into my.skill23 = player.z;

Add before the wait(1); comment above for example this:

if(vec_dist(vector(my.skill21,my.skill22,0),vector(player.x,player.y,0) > 64) {
climb = 0;
break;
}
Posted By: 3run

Re: ladder detection - 02/22/10 17:49

Thank you. Changed it like this, needs testing and so on... Bugy a little bit. If any other ideas will be very greatful.

Code:
function ladder_event()
{
	if(you)
	{
		if(you == player)
		{
			my.enable_impact = off;	//prevent the event to be triggered again and again during climbing
			vec_set(my.skill21,player.x);	//store the players position
			while(1)
			{
				proc_late();
				climb = 1;
				player.z = my.skill23;
				my.skill30 = c_move(player,ladder_movement,nullvector,ignore_passable|ignore_passents|glide);	//move the player up or down
				if(camera.tilt > - 40)
				{
					ladder_movement.z = 25 * (key_w - key_s)*time_step;
			   } 
			   if(camera.tilt < - 40)
			   {
			   	ladder_movement.z = 25 * (key_s - key_w)*time_step;
			   }
			   ladder_movement.x = 0;
			   ladder_movement.y = 25*(key_a - key_d)*time_step;
			   
			   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) );
			   
			   vec_set(trace_coords.x, vector(400, 0, 0)); 
			   vec_rotate(trace_coords.x, player.pan);
			   vec_add(trace_coords.x, player.x);
			   
			   c_trace(player.x, trace_coords.x, IGNORE_ME | GLIDE); 
			   if(trace_hit){allow_climb = 1;}else{allow_climb = 0;}
			   if(vec_dist(vector(my.skill21,my.skill22,0),vector(player.x,player.y,0)) > 64 || key_space == 1)	
				{
					climb = 0;
					break;	
				}
				my.skill23 = player.z;
				wait(1);
			}
			climb = 0;
			wait(-0.1);	
			my.enable_impact = on;	
		}
	}
}


Posted By: 3run

Re: ladder detection - 02/23/10 18:04

SOME ONE! NEED HELP WITH THIS THING!!!
Posted By: Superku

Re: ladder detection - 02/23/10 18:18

Originally Posted By: 3run
Damn! Will some one try to help?! I even posted my script!!!!!!


Originally Posted By: 3run
SOME ONE! NEED HELP WITH THIS THING!!!

Posted By: Random

Re: ladder detection - 02/23/10 18:31

There is an alot easyer way to do that, Newbie helps Member :D;

Wolla;
__________________________________________________________________________________
action ladder()
{
my.emask |= (ENABLE_IMPACT | ENABLE_ENTITY);
my.event = ladder_event;
set(my,POLYGON);
c_setminmax(me);
}

function ladder_event()
{
if(you)
{
if(you == player)
{
my.emask = NULL;
vec_set(my.skill21,player.x);
vec_set(my.skill24,player.pan);
}
while(1)
{
proc_mode = PROC_LATE;
vec_set(player.x,my.skill21);
vec_set(player.pan,my.skill24);
my.skill30 = c_move(player,nullvector,vector(0,0,(key_w-key_s)*my.skill1*time_step),IGNORE_PASSABLE|IGNORE_PASSENTS|GLIDE);
if((key_s && my.skill30 < 0.1) || (key_w && (player.z+player.min_z) > (my.z+my.max_z+player.max_z)))
{
break;
}
vec_set(my.skill21,player.x);
wait(1);

wait(-0.1);
my.emask = ENABLE_IMPACT;
}
}
}
_______________________________________________________________
Posted By: 3run

Re: ladder detection - 02/23/10 19:14

Doesn't work man frown 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:
Code:
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:
Code:
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 frown please help me.
Posted By: Random

Re: ladder detection - 02/25/10 18:42

Realey?
It works with the player from intense x.
Posted By: 3run

Re: ladder detection - 02/25/10 23:22

I know, it works laugh but not the way I want it to... Need to calculate in x coordinates, and make player leave the ladder as soon, as he turns away from it... But have no idea how to make all that... frown
Posted By: 3run

Re: ladder detection - 02/28/10 08:46

Can some very kind person, help me to calculate dist from ladder to player in X coordinates? It's already done, but only in Y and Z coordinates... Need the same thing but only in X coordinates. I know, I'm not making any sense by just always asking for it... But this piece of player movemet really makes me going crazy... I've done every thing in player movement script for my FPS game called War Cloud. Only two things left... First is this ladder script (damn I really hate it frown )... And second is elevators, but it will be easy to do... With help of AUM tutorials laugh I've tryed to get all that to work by myself... You can see it from my scripts I've posted... But I always fail frown can't make the player leave the damn ladder when he walks away from it in X coordinates...
Posted By: 3run

Re: ladder detection - 02/28/10 13:18

Really need some ones help frown I can't figure out this alone...
Posted By: Nidhogg

Re: ladder detection - 02/28/10 13:34

Try something like,
if (player.pan && (player.z = ?)
{
exit ladder;
return;
}
Posted By: 3run

Re: ladder detection - 02/28/10 17:55

I've tried similar to Z coordinates, like this:
if(player.x + player.min_x - 30 > my.max_x)
{
break;
climb = 0;
}
But not working any way... frown played with 30, doesn't make any sense... Now I hate ladder man... frown
Posted By: 3run

Re: ladder detection - 02/28/10 23:20

No one giving me the answer, for question I'm asking for... Is that so hard to help such newbie as me? Only thing I'm asking for is calculating distanse from ladder to player as it is already done in Y coordinates, need the same, but only in X coordinates, so if player for example walks backwards (or forward) from the ladder, and distanse is bigger for example than 15 (or smaller than -15), then player must leave the ladder... Will be very effective to create a ladder script I guess... I've stucked in this damn piece of script... frown no problem with leaving the ladder, if player turned away from it, I'll fix it on myself, that will be very easy, player will be not able to turn away from it, he can only look around. I understand that I'm really badass and may be even asking too much, but I really stuck here frown please some one, be so kind and help me. I'll be really grateful and will add name of person who will help me out, in the credits of my game, as a programmer that helped me with my game...
Posted By: Superku

Re: ladder detection - 03/01/10 00:39

if(vec_dist(vector(ladder.x,ladder.y,0),vector(player.x,player.y,0)) > 20) {}
Posted By: 3run

Re: ladder detection - 03/01/10 09:25

Thank you bro, but I've tried like that already... Doesn't work frown it calculates distanse only from the center of the model... Works if player is in the middle of the ladder... If in the top for example, doesn't help... frown
Posted By: Pappenheimer

Re: ladder detection - 03/01/10 18:47

Is your ladder actually upright? Superku's line should work independently whether the player is in the middle or at any end of the ladder, because of the zero at the z value of the vectors.

Just an idea, replace "0" in both vectors by "player.z".
Posted By: 3run

Re: ladder detection - 03/01/10 18:54

Now it works well... Just need some testing and ladder script need some improvements laugh Thank you Superku!!! You're the best! laugh I'll add you in the credits of my project laugh Thank you all!
Posted By: Superku

Re: ladder detection - 03/01/10 19:13

Your welcome! But you don't have to add me wink
What are you doing, a parkour game?
Posted By: 3run

Re: ladder detection - 03/01/10 19:22

No laugh just some kind of Call of Duty killer grin multiplayer shooter... Player script with weapons are close to be finished laugh just need some bag fixes and so on. I'll add you in credits any way laugh will say that you are very kind and clever person, and that you helped me much with this damn ladder script wink solution is very simple and great laugh never thought about using vec_dist
© 2024 lite-C Forums