Game Development Community

AI Movement

by PrvtHudson · in Technical Issues · 12/29/2006 (11:12 pm) · 3 replies

I want to have my NPC run along a wall when he hits it. I have been learning from my 3D Math Primer and here is my plan so far.

I create 3 points with the eye vector and 2 ray cast points from the eye. The second ray has an arbitary offset. This gives me a triangle. I subtract the two points(vectors) from the raycasts to get the "wall vector". I scale that vector and send my bot to the "point". He, apparently not impressed with my math skills, turns around and walks the other away.

Can anyone point me in the right direction? It seems to me that I am assuming that the raycast returns the point of intersection and not the object(map) position.

// ---------------------------------------------------------------------------------------------------------->
%object = ContainerRayCast(%startPoint, %endPoint, %searchMasks, %player );
%point1 = GetWords(%object, 1,3);

// Get the second point
%vecOffset = "5 0 0";
%endPoint = VectorAdd(%startPoint, %vecOffset);

%object2 = ContainerRayCast(%startPoint, %endPoint, %searchMasks, %player );
%point2 = GetWords(%object2, 1,3);

%vecSub = VectorSub(%point1, %point2);
%vecScale = VectorScale(%vecSub,10);

%this.setMoveDestination(%vecDest);
%this.setMoveSpeed(0.25);

#1
06/13/2007 (11:22 am)
A raycast returns the handle of the object it hits. I'm doing something similar and have been trying to figure out the point of intersection, too.
#2
06/13/2007 (12:05 pm)
I dont see anywhere in the code where %vecDest is set.
#3
06/13/2007 (2:56 pm)
Is getWords() a valid function? I thought that it was getWord().....

p.s. When my bots insult me I always show them how rocket propelled grenades work :-). Our math skills are better than theirs!!!