Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Vector math: I need to find a pos just a little in front of an actor
Vector math: I need to find a pos just a little in front of an actor
2004-09-14, 6:41 PM #1
I want to grab a posistion thats just a hair in front where an actor is looking (an easily variable distance) I'm using this code from chainlighting cog so I'm not sure if its exactly what I want.

   dir = VectorNorm(VectorSub(GetThingPos(target), GetThingPos(ai)));
   pos = VectorAdd(GetThingPos(ai), VectorScale(dir, 0.07));

Pos should now be a posistion about 0.07JKUs in front of us right?
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2004-09-14, 6:58 PM #2
Theoretically, your code should work.
But if it doesn't (again, I don't see why it shouldn't, unless there's no target), here's an alternative you can try.
projectile = FireProjectile(actor, LoadTemplate("+bryarbolt"), -1, -1, '0 0.07 0', '0 0 0', 0, 0, 0, 0);
pos = GetThingPos(projectile);
May the mass times acceleration be with you.
2004-09-15, 6:05 AM #3
Heh, I actually already had that code same code alternative up and going before you replied. The original worked fine, but I'd misread one of my debugging printouts and thought it was failing.

What I'm doing is writing some code for AI I'm working on, specifically the section about pit avoidance. I use that code along with FindSectorAtPos() (and my new found knowledge that the verb will return -1 when used on a position without a sector) to determine the depth of pits.

This implementation may need to be scrapped though because 3do architecture will NOT be detected using a FindSectorAtPos() system. I may be forced to use instant hit projectiles and have their removed message report (through sendmessage()?) the depth of the pit.

I'd rather not do it that way, because instant hit projectiles have their own problems as seen in other recent threads...and because grabbing the data from a destroyed projectile is messy and can't be performed 'in the box' of the AI cog...(virtually) instantly. I'd also end up having to fire many projectiles to figure out the width of the pit gap...a value I will need if I want the AI to attempt to jump across the pit.

In the end, I may just build the level around the AI.
-El Scorcho

"Its dodgeball time!" -Stormy Waters

↑ Up to the top!