PDA

View Full Version : Finding Aiming Vector



nerdboy_2000
01-27-2001, 01:57 PM
When using FireProjectile one of the parameters is a vector on how to fire it. I want that vector to aim at a moving object so I need to know how to get the vector for one thing to fire at another. How would I do that?

Jipe
01-27-2001, 02:34 PM
player = GetLocalPlayerThing();
blah = FirstThingInView();
blah2 = GetThingPos(blah);
avector = VectorSub(player, blah2);
FireProjectile(avector goes in the parameter(s) that you need for vectors, here);

Try it. Need to fill in parameters for FirstThingInView(), I believe Hideki's site has it (http://millennium.massassi.net).

-Jipe

nerdboy_2000
01-27-2001, 04:08 PM
It almost works, but it fires the projectile about 90 degrees to the right.

Hideki
01-27-2001, 05:14 PM
Try this.



op = FirstThingInView(player, aimFovDist, aimFovAngle, 0x404);

pPos = GetThingPos(player);
oPos = GetThingPos(op);

aimVec = VectorSub(pPos, oPos);
FireProjectile(player, template, sound, key, fromVec, aimVec, 1, aimFovDist, aimFovAngle);



------------------
http://millennium.massassi.net/ - Millennium