Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,731 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c_trace #328422
06/13/10 05:38
06/13/10 05:38
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
I need to make right from the players feet 3 different traces, to the right, left and to the back. Players origin is in the middle of the model, but trace I need right from under the players feet, how that can be done? Thank you.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: c_trace [Re: 3run] #328432
06/13/10 07:32
06/13/10 07:32
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Errr ...

Dont really know what you mean, but is this it?

Code:
...
	while(me)
	{
		...
		
		//calculate 'START-of-trace' vectors
		vec_set(s_leftV, vector(0,0, my.min_z));		//local co-ord of feet
		vec_rotate(s_leftV, my.pan);						//rotate to players facing direction
		vec_add(s_leftV, my.x);								//position 'around' player
	
		vec_set(s_backV, vector(0,0, my.min_z));		//local co-ord of feet
		vec_rotate(s_backV, my.pan);						//rotate to players facing direction
		vec_add(s_backV, my.x);								//position 'around' player
	
		vec_set(s_rightV, vector(0,0, my.min_z));		//local co-ord of feet
		vec_rotate(s_rightV, my.pan);						//rotate to players facing direction
		vec_add(s_rightV, my.x);							//position 'around' player
	
		//
		//calculate 'END-of-trace' vectors
		vec_set(e_leftV, vector(0,-500, my.min_z));	//trace distances (from feet)
		vec_rotate(e_leftV, my.pan);						//rotate to players facing direction
		vec_add(e_leftV, my.x);								//position 'around' player
		
		vec_set(e_backV, vector(-500,0, my.min_z));	//trace distances (from feet)
		vec_rotate(e_backV, my.pan);						//rotate to players facing direction
		vec_add(e_leftV, my.x);								//position 'around' player
		
		vec_set(e_rightV, vector(0,500, my.min_z));	//trace distances (from feet)
		vec_rotate(e_rightV, my.pan);						//rotate to players facing direction
		vec_add(e_leftV, my.x);								//position 'around' player
	
	
		c_trace(s_leftV, e_leftV, IGNORE_ME);			/*	debugging --> */	draw_line3d(s_leftV, NULL, 100);	draw_line3d(e_leftV.x, vector(0,255,0), 100);
	
		c_trace(s_backV, e_backV, IGNORE_ME);			/*	debugging --> */	draw_line3d(s_backV, NULL, 100);	draw_line3d(e_backV.x, vector(0,0,255), 100);
	
		c_trace(s_rightV, e_rightV, IGNORE_ME);		/*	debugging --> */	draw_line3d(s_rightV, NULL, 100);	draw_line3d(e_rightV.x, vector(255,0,0), 100);
		//
		//
		wait(1);
	}
...




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: c_trace [Re: EvilSOB] #328496
06/13/10 15:57
06/13/10 15:57
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus
Here are some bugs found by me dude:




When I play with distance of traces, they be came some weird and wrong. All other things work just great, but how to figer out with this bug? Can upload the demo.

Last edited by 3run; 06/13/10 15:57.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: c_trace [Re: 3run] #328555
06/13/10 21:34
06/13/10 21:34
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Before you post the demo, let us try a couple of things...

But firstly, now I am more awake, I notice that all 3 of the 'trace-from'
vectors will always be the same value, because they are the same point.
so cut that down to one calculation and use it in all three traces to save CPU.

Secondly, when you say you are 'playing with the distances', what do you mean?
Revember the trace-to vectors MUST have thier Z value = my.min_z before the
vec_rotate and vec_add otherwise the trace will start going
'uphill' or 'downhill' from the feet.

Or did you want the traces to go left/right/back from his feet but scan parallel to the ground?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: c_trace [Re: 3run] #328564
06/13/10 23:14
06/13/10 23:14
Joined: Jan 2002
Posts: 300
Usa
Rich Offline
Senior Member
Rich  Offline
Senior Member

Joined: Jan 2002
Posts: 300
Usa
This is something I threw together quickly. It traces behind and to the sides of an object, relative to it's pan. I used a similar code to draw my player's axis for debug purposes.


Note :
-you will need a temporary vector "temp_vec" defined somewhere.
-trace_dist is how far away from the object the trace will scan.
-The result will be 0 unless you are near something (like my screenshot below I had walls to all sides of the object).
-I used the z value of " my.z + my.min_z + 1 ", which is the base of the object's collision hull + 1 (upward), the + 1 will keep the trace above ground level (hopefully).

Code:
var trace_dist = 100 // distance of trace

///////////////

   //trace behind
   vec_set(temp_vec, vector(my.x-(trace_dist*cos(my.pan)),  my.y-(trace_dist*sin(my.pan)), my.z+my.min_z+1) );
   c_trace(vector(my.x,my.y,my.z + my.min_z+1),temp_vec, IGNORE_ME | IGNORE_PASSABLE); //TRACE
   

   //trace left
   vec_set(temp_vec, vector(my.x-(trace_dist*cos(my.pan-90)),  my.y-(trace_dist*sin(my.pan-90)), my.z+my.min_z+1) );
   c_trace(vector(my.x,my.y,my.z + my.min_z+1),temp_vec, IGNORE_ME | IGNORE_PASSABLE); //TRACE LEFT
   

   //trace right
   vec_set(temp_vec, vector(my.x-(trace_dist*cos(my.pan+90)),  my.y-(trace_dist*sin(my.pan+90)), my.z+my.min_z+1) );
   c_trace(vector(my.x,my.y,my.z + my.min_z+1),temp_vec, IGNORE_ME | IGNORE_PASSABLE); //TRACE



same code, with added code to draw lines.
Code:
var trace_dist = 100 // distance of trace

///////////////

      //trace behind
   vec_set(temp_vec, vector(my.x-(trace_dist*cos(my.pan)),  my.y-(trace_dist*sin(my.pan)), my.z+my.min_z+1) );
   c_trace(vector(my.x,my.y,my.z + my.min_z+1),temp_vec, IGNORE_ME | IGNORE_PASSABLE); //TRACE
   
					// draw line green
					   vec_set(temp_vec, vector(my.x-(result*cos(my.pan)),  my.y-(result*sin(my.pan)), my.z+my.min_z+1) );
					   draw_line3d(my.x,COLOR_GREEN,0);  
					   draw_line3d(vector(my.x,my.y,my.z+my.min_z),COLOR_GREEN,100);
					   draw_line3d(temp_vec,COLOR_GREEN,100);
					   draw_line3d(temp_vec,COLOR_GREEN,0);
					//
   //trace left
   vec_set(temp_vec, vector(my.x-(trace_dist*cos(my.pan-90)),  my.y-(trace_dist*sin(my.pan-90)), my.z+my.min_z+1) );
   c_trace(vector(my.x,my.y,my.z + my.min_z+1),temp_vec, IGNORE_ME | IGNORE_PASSABLE); //TRACE LEFT
   
					//   draw line red
					   vec_set(temp_vec, vector(my.x-(result*cos(my.pan-90)),  my.y-(result*sin(my.pan-90)), my.z+my.min_z+1) );
					   draw_line3d(my.x,COLOR_RED,0);
					   draw_line3d(vector(my.x,my.y,my.z+my.min_z),COLOR_RED,100);
					   draw_line3d(temp_vec,COLOR_RED,100); 
					   draw_line3d(temp_vec,COLOR_RED,0);  
					//
   //trace right
   vec_set(temp_vec, vector(my.x-(trace_dist*cos(my.pan+90)),  my.y-(trace_dist*sin(my.pan+90)), my.z+my.min_z+1) );
   c_trace(vector(my.x,my.y,my.z + my.min_z+1),temp_vec, IGNORE_ME | IGNORE_PASSABLE); //TRACE
   
					//draw line blue
					   vec_set(temp_vec, vector(my.x-(result*cos(my.pan+90)),  my.y-(result*sin(my.pan+90)), my.z+my.min_z+1) );
					   draw_line3d(vector(my.x,my.y,my.z+my.min_z),COLOR_BLUE,0);   
					   draw_line3d(vector(my.x,my.y,my.z+my.min_z),COLOR_BLUE,100);
					   draw_line3d(temp_vec,COLOR_BLUE,100);   
					   draw_line3d(temp_vec,COLOR_BLUE,0); 
					//







Last edited by Rich; 06/13/10 23:43.

A8 com / A7 free
Re: c_trace [Re: Rich] #330167
06/26/10 01:08
06/26/10 01:08
Joined: May 2009
Posts: 5,377
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,377
Caucasus

Look what happens frown Looks like they all mixed together...

Last edited by 3run; 06/26/10 01:10.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | 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