Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, howardR), 1,001 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: scan_path question [Re: bobby_danseco] #329412
06/19/10 17:27
06/19/10 17:27
Joined: Dec 2005
Posts: 116
T
tD_Datura_v Offline
Member
tD_Datura_v  Offline
Member
T

Joined: Dec 2005
Posts: 116
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);
	}
}






Re: scan_path question [Re: tD_Datura_v] #336984
08/07/10 11:31
08/07/10 11:31
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline
User
Carlos3DGS  Offline
User

Joined: Oct 2008
Posts: 513
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);


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Page 2 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1