Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Kingware, AemStones, RealSerious3D), 1,388 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 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 | 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