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
1 registered members (TipmyPip), 18,631 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
Increase Vector Range #350810
12/19/10 12:48
12/19/10 12:48
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
Hi,

i´ll make it short. I have a 3rd Person View. I can see my player from behind and i have a crosshair. I´m aiming with the crosshair und tracing from camera to the crosshair. It works fine so far.

If the player starts to shoot i´m tracing from the players gun to the camera´s trace target to check if there´s something between.

but the problem now is. sometimes the trace doesnt hit. I think it because it stop before the target.

Now i want to know if i can increase my Vector that the camera trace target is pushed a few quants behind it´s trace so that my player´s tracing for example into the wall.

This is my camera trace code.
Code:
VECTOR to;
vec_set(to, mouse_dir3d);
vec_scale(to, 5000); // set a range
vec_add(to, camera.x);
c_trace(camera.x, to, IGNORE_PASSABLE); // Trace from cam
		
vec_set(camera_target, hit.x); // save the target



And this is my player trace code.
Code:
vec_for_vertex(muendung, player, 508); // Weapon Muzzle
		
c_trace(muendung, camera_target, IGNORE_PASSABLE); // trace from muzzle to target
		
if(trace_hit)
{
	you.health -= integer(random(25))+80;
	ent_create(einschussloch,hit.x,einschuss); // create bullet hole
	leuchtgeschoss(muendung); // another function
}



I tried to vec_scale and vec_normalize my camera_target but i dont get it. ANy help please?

Thank you laugh

Re: Increase Vector Range [Re: Rasch] #350817
12/19/10 13:17
12/19/10 13:17
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
wrote this in notepad, i think i should work but even if it doesnt i guess it gives the idea:

VECTOR tmpv;
vec_diff(tmpv, muendung.x, camera_target.x); //tmpv's now the vector from my.x to target.x
vec_normalize(tmpv, 1); //increase length by "1"
vec_add(muendung.x, tmpv); //add that to the target

c_trace(muendung, camera_target, IGNORE_PASSABLE); // trace from muzzle to target

goodluck

Re: Increase Vector Range [Re: darkinferno] #350844
12/19/10 17:17
12/19/10 17:17
Joined: Jun 2008
Posts: 428
Rasch Offline OP
Senior Member
Rasch  Offline OP
Senior Member

Joined: Jun 2008
Posts: 428
hmm thanks so far. but that didnt work. Any other idea?

ok it worked. i thought about it again and changed the code to this.

Code:
VECTOR tmpv;
		vec_diff(tmpv, camera_target.x, muendung.x); //tmpv's now the vector from my.x to target.x
		vec_normalize(tmpv, 1); //increase length by "1"
		vec_add(camera_target.x, tmpv); //add that to the target*/



Now it works. because it adds the quants to the target.

Thank you very much wink

Last edited by Rasch; 12/19/10 17:35.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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