Gamestudio Links
Zorro Links
Newest Posts
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 (ozgur, AbrahamR, wdlmaster, 7th_zorro), 839 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Vector Help Please! #398867
04/08/12 02:37
04/08/12 02:37
Joined: Jun 2009
Posts: 26
D
dd231 Offline OP
Newbie
dd231  Offline OP
Newbie
D

Joined: Jun 2009
Posts: 26
Hey there,

I am having a hard time wrapping my mind around the proper way to set a bullet in front of a character's x axis and relative to their pan. I think I'm missing something simple and I am over complicating things... however if you could point me in the right direction it would be much appreciated! Here is what I'm working with....

//STATE == ATTACK
if(my.state ==2)
{
if(you.health <= 0) {my.state = 0;} vec_set(detect_box.x,vector(you.x,you.y,you.z+13));
// ent_animate(my,"attack",my.attack_percent,0);
my.attack_percent += 4*time_step;
// if(vec_to_angle(my.pan,vec_diff(NULL,you.x,my.x)) > 0) pXent_rotate(my,my.pan,vector(6*time_step,0,0));
//
if(my.attack_percent > 100)
{
ENTITY* bullet = ent_create("bullet.mdl",vector(my.x+100,my.y+13,my.z),move_bu;
bullet.x += 100*sin(my.pan+85);
bullet.y -= 100*cos(my.pan+85);
bullet.pan = my.pan+random(8);
bullet.tilt = head_bone.tilt;
ent_playsound(my,gunshot,500);
my.attack_percent =0;
wait(8);

Re: Vector Help Please! [Re: dd231] #398869
04/08/12 02:56
04/08/12 02:56
Joined: Jun 2009
Posts: 26
D
dd231 Offline OP
Newbie
dd231  Offline OP
Newbie
D

Joined: Jun 2009
Posts: 26
Lol sorry for the false alarm....
Figured it out... here it is for anyone else with a similar problem

ENTITY* bullet = ent_create("bullet.mdl",vector(my.x+100*sin(my.pan+85),my.y-100*cos(my.pan+85),my.z),move_bullets);

knew I was on the right path with the trig!

Re: Vector Help Please! [Re: dd231] #398936
04/08/12 23:58
04/08/12 23:58
Joined: Jun 2004
Posts: 2,234
Wisconsin USA
FoxHound Offline
Expert
FoxHound  Offline
Expert

Joined: Jun 2004
Posts: 2,234
Wisconsin USA
That is the right idea and how I would do it but the +85 should put the bullet to start a bit either to right or left (I forget which way that is). If the plan is to use this for a 3rd person shooter you are doing good. However in that case I would use vec_for_vertex and put the bullet in the exact spot where the barrel of the gun is.

However you have a +100 and a -100 in your formula and I'm not sure what that would do so maybe I'm way off here.


---------------------
There is no signature here.


QUIT LOOKING FOR ONE!

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