scan_path question

Posted By: bobby_danseco

scan_path question - 06/13/10 14:19

hi.. i used the scan_path example from the manual
to move a player in a circle or a loop and its working fine
but.. for some reason there are cases that the player
is moving up above the knee of the other player.
and retain that level. any reason why this thing happen?

thanks... laugh
Posted By: Superku

Re: scan_path question - 06/13/10 14:40

If you mean path_scan, then the reason is the example code does not use a gravity code and uses GLIDE.
Posted By: bobby_danseco

Re: scan_path question - 06/13/10 20:20

yup.. path_scan.. sorry about that. laugh
if it is so.. then i have to put gravity code. frown

thanks..
Posted By: Ottawa

Re: scan_path question - 06/14/10 00:21

Hi!


Or tell your player to stay x quants off the ground.
before or after the c_move.
Posted By: bobby_danseco

Re: scan_path question - 06/14/10 05:25

thnks ottawa and superku laugh
Posted By: bobby_danseco

Re: scan_path question - 06/14/10 13:05

hi.. i try to put my.z = -180 before or after cmove (wherein -180 is my level on the ground) but still player is going up frown

i also try this but no success..
Code:
vec_set(tmp_vec, my.x);
tmp_vec.z -= 1000;
boot_dist.z = -abs(c_trace (my.x, tmp_vec, IGNORE_ME | IGNORE_PASSABLE));
		
c_move(my,vector(boot_dist,nullvector, IGNORE_YOU | IGNORE_PASSABLE | IGNORE_WORLD | GLIDE );



thanks for any help laugh
Posted By: Ottawa

Re: scan_path question - 06/15/10 00:33

Hi!
1)
Is this in a loop?

You could try
2)
vec_set(tmp_vec.x, my.x);
or
vec_set (tmp_vec.x, vector(my.x,my.y,my.z-180)); // player's pos copied to ???

What is boot_dist.z ?
I believe that this value is changing all the time in your C_move.
Posted By: bobby_danseco

Re: scan_path question - 06/15/10 05:44

thanks for the time ottawa actually
this what ive got. this is working perfectly well in some area
there there are some points that the players is gliding up
on some waypoint. i only have 4 nodes on each path.

just to give you a clear picture.
maybe you or anyone can help me on how i can maintain the player on
-180

may thanks.. laugh

Code:
function boot_player()
{
	
	my.ambient=100;
	// attach entity to nearest path
	result = path_scan(me,my.x,my.pan,vector(360,180,1000));
	if (result == 0) { return; } // no path found
	
	// find first waypoint
	var node = 1; // start at first node
	path_getnode(my,node,my.skill20,NULL);
	
	while (1)
	{
		var angle[3];
		// find direction
		result = vec_to_angle(angle,vec_diff(temp,my.skill20,my.x));
		
		// near target? Find next waypoint of the path
		if (result < 25) {
			node = path_nextnode(my,node,1);
			path_getnode(my,node,my.skill20,NULL);
			my.z = -180;
			if(node==3)
			{
				my.z = -180;
				node=1;
				result = path_scan(me,my.x,my.pan,vector(360,180,1000));
				path_getnode(my,node,my.skill20,NULL);
				my.z = -180;
			}
		}
		
		// turn and walk towards target
		//
		my.pan = angle[0];
		//my.z = -180; //<==if i put this it will stuck on the point where the player is gliding.
		
		//c_move(me,vector(3*time_step,0,0),NULL,GLIDE); // walk ahead...
		
		c_move(my,vector(3*time_step,0,0),nullvector, IGNORE_YOU | IGNORE_PASSABLE | IGNORE_WORLD | GLIDE ); //moves the player
		
		my.skill[41] += 6*time_step;
		if(my.skill[41] > 100) {my.skill[41] = 0;}
		ent_animate(my,"walk",my.skill[41],ANM_CYCLE);
		
		wait(1);
	}
	
}


Posted By: Ottawa

Re: scan_path question - 06/16/10 12:41

Hi!

Here's a suggestion :
Place the declaration of var at the beginning of the function
Code:
function boot_player()
{
var node = 1; // start at first node
var angle[3]; // this should not get declared every time 
 ....



I'll look further.
edit :
I don't think you need the c_move
the get next node (path_getnode) gets you to the next node and so on.
Posted By: bobby_danseco

Re: scan_path question - 06/19/10 14:26

hi..
thank ottawa.. i did what you said.
still the same thing.. gliding up. frown

really appreciate your help. laugh

many thanks..
regards.
bobby
Posted By: tD_Datura_v

Re: scan_path question - 06/19/10 17:27

Code:
// C-Script
/*
	This sample is an attempt at combining the gravity / movement sample found in the manual entry "c_move"
	(attributed to jcl?) and a path movement sample found in this thread.
	It is an example which may be used to help determine what, or what not, to do.
	
*/
define _nodePos, skill20;

function evf_getFloor() {
	var vDown[3]; vec_set(vDown, my.x);
	var evResult; evResult = 0;
	var vFeet[3]; 
	vec_for_min(vFeet, me);
	vDown.z -= (my.max_z - my.min_z) * 3;
	evResult = c_trace(my.x, vDown, IGNORE_ME | IGNORE_PASSABLE | USE_BOX);
	if (trace_hit) {
		evResult = my.z + vFeet.z - target.z;
	} else {
		evResult = 666;
	}
	return(evResult);
}

function boot_player() {
	var nodeResult; nodeResult = 0;
	var node; node = 1; // start at first node
	var angle[3]; vec_set(angle, nullvector);
	var evDistZ; evDistZ = 0;
	var distX; distX = 0;
	var speedZ; speedZ = 0;
	
	my.ambient=100;
	// attach entity to nearest path
	nodeResult = path_scan(me,my.x,my.pan,vector(360,180,1000));
	if (nodeResult == 0) { return; } // no path found
	path_getnode(my,node,my._nodePos,NULL);
	
	while (me != NULL) {
		nodeResult = vec_to_angle(angle, vec_diff(temp, my._nodePos, my.x));
		if (nodeResult < 25) {
			node = path_nextnode(me,node,1);
			if (node == 3) {
				node=1;
				nodeResult = path_scan(me,my.x,my.pan,vector(360,180,1000));
			}
			path_getnode(my,node,my._nodePos,NULL);
		}
		
		// turn to node pos
		my.pan = angle[0];
		//my.z = -180; //<==if i put this it will stuck on the point where the player is gliding.
		
		//c_move(me,vector(3*time_step,0,0),NULL,GLIDE); // walk ahead...
		evDistZ = evf_getFloor();
		if (evDistZ > 0) {
			evDistZ = clamp(evDistZ, 0, accelerate(speedZ, 5, 0.1));
		} else {
			speedZ = 0;
		}
		distX = 3 * time_step;
		distX = sign(distX) * (abs(distX) + 0.5 * evDistZ);
		c_move(my,vector(distX,0,0), vector(0, 0, -evDistZ), IGNORE_YOU | IGNORE_PASSABLE | IGNORE_WORLD | GLIDE ); //moves the player
		// animation
		my.skill42 += 6*time_step;
		if(my.skill42 > 100) {my.skill42 = 0;}
		ent_animate(my,"walk",my.skill42,ANM_CYCLE);
		
		// test camera
		// temp.x = (my.max_x - my.min_x) * -3; temp.y = 0; temp.z = 0;
		// vec_rotate(temp, my.pan);
		// vec_add(temp, my.x);
		// vec_set(camera.x, temp);
		// vec_diff(temp, my.x, camera.x);
		// vec_to_angle(camera.pan, temp);
		wait(1);
	}
}


Posted By: Carlos3DGS

Re: scan_path question - 08/07/10 11:31

If you are not using a default model I think your problem might be related to a mistake I also used to make when I started with 3Dgamestudio...

It seems like the bounding box is alot bigger than your visible model, to fix this follow two steps:

1. Open you model in med. You probably have the "feet" of you model at the center of the grid, correct this by placing the model CENTERED at the origin of x,y,z in med (this means that that your model in med has to have his stomach at the center of the grid). If you dont understand what I mean or you want it to be exactly at the center there is a way to achieve this automatically in med. Load your model in med, open the "edit" menu -> "transform model global" -> and click "center model".

2. In you model's action function add this line at the beginning to make sure the bounding box used for detecting collisions is exactly the same size as your model:
c_setminmax(me);
© 2024 lite-C Forums