Problem with raycast
by Bristow · in Torque Game Engine · 08/01/2006 (9:21 am) · 1 replies
Ok I've basically been using this for a bot's line of site:
So it looks 60 feet ahead on the y-axis to get the end position. But the obvious problem I realize now is that this just projects the line 60 feet on the Y, so if I turn any of my bots they line of site will still be going in the same ditrection.
I was wondering is there a way to make a ray cast go from, a bot's face (I figured %this.geteyepostion) to 60 feet or w/e amount in the direction that the bot is facing
%searchMasks = ($TypeMasks::playerObjectType); %pos = (VectorAdd(%this.getTransform(), "0 0 1")); %end = (VectorAdd(%this.getTransform(), "0 60 1")); %scanTarg = ContainerRayCast (%pos, %end, %searchMasks, %this);
So it looks 60 feet ahead on the y-axis to get the end position. But the obvious problem I realize now is that this just projects the line 60 feet on the Y, so if I turn any of my bots they line of site will still be going in the same ditrection.
I was wondering is there a way to make a ray cast go from, a bot's face (I figured %this.geteyepostion) to 60 feet or w/e amount in the direction that the bot is facing
About the author
Torque Owner Stefan Lundmark
%startPoint = %bot.getEyeTransform (); %startPoint = getWords ( %startPoint, 0, 2 ); // Probably not needed. %eyeVector = %bot.getEyeVector (); %eyeVector = VectorScale ( %eyeVector, 60 ); %endPoint = VectorAdd ( %startPoint, %eyeVec );