Ai Los Help
by Eric Dunn · in Technical Issues · 11/19/2003 (11:51 am) · 2 replies
Im trying to implement some LOS(line of sight) for my bots that wander around from waypoint to waypoint. My problem is I cant seem to get it working and was hoping someone could give me a tip.
Here is the functions that I wrote in AIPlayer.cc:
bool AIPlayer::checkLOS(Point3F location)
{
RayInfo RayEvent;
MatrixF eyeTransform;
getEyeTransform(&eyeTransform);
U32 mask = StaticShapeObjectType | InteriorObjectType | VehicleObjectType;
if(getContainer()->castRay(eyeTransform.getPosition(), location, mask, &RayEvent))
return true;
return false;
}
ConsoleMethod(AIPlayer, checkLOS, bool, 3, 3, "ai.checkLOS(Point3F);")
{
AIPlayer *ai = static_cast(object);
Point3F pos;
dSscanf(argv[2], "%f %f %f", &pos.x, &pos.y, &pos.z);
return ai->checkLOS(pos);
}
Im basically checking from my bot's eye, to a waypoint position in my script, and it always gives me NOT in LOS. I do not have TerrainObjectType or PlayerObjectType specified in the mask, bcuz i dont want those as collision factors. Im still fairly new to Torque and am not sure if im using castRay() correctly or if i wrote the ConsoleMethod correctly.
Any help would be appreciated, I just want my bots to be able to check if there is a object in its path before heading to a waypoint.
Also, i have another problem with bots moving to a particular unspecified waypoint, or position, dont know why they are doing that.
Here is the functions that I wrote in AIPlayer.cc:
bool AIPlayer::checkLOS(Point3F location)
{
RayInfo RayEvent;
MatrixF eyeTransform;
getEyeTransform(&eyeTransform);
U32 mask = StaticShapeObjectType | InteriorObjectType | VehicleObjectType;
if(getContainer()->castRay(eyeTransform.getPosition(), location, mask, &RayEvent))
return true;
return false;
}
ConsoleMethod(AIPlayer, checkLOS, bool, 3, 3, "ai.checkLOS(Point3F);")
{
AIPlayer *ai = static_cast
Point3F pos;
dSscanf(argv[2], "%f %f %f", &pos.x, &pos.y, &pos.z);
return ai->checkLOS(pos);
}
Im basically checking from my bot's eye, to a waypoint position in my script, and it always gives me NOT in LOS. I do not have TerrainObjectType or PlayerObjectType specified in the mask, bcuz i dont want those as collision factors. Im still fairly new to Torque and am not sure if im using castRay() correctly or if i wrote the ConsoleMethod correctly.
Any help would be appreciated, I just want my bots to be able to check if there is a object in its path before heading to a waypoint.
Also, i have another problem with bots moving to a particular unspecified waypoint, or position, dont know why they are doing that.
About the author
Torque Owner Mz