Steve_Yorkshire Posted June 23, 2017 Share Posted June 23, 2017 I'm having trouble getting a function to identify the object it hits. I want it to return true if it's target is hit and only it's target. When I hide behind other players/AI it returns true even though the view should be blocked by said other player objects.I had started off with a simpleif (rInfo.object == target) return true;But that didn't block the raycast with other players.Full code for the function below: bool AIPlayer::checkClearLos(GameBase* target, bool _checkEnabled) { if (!isServerObject()) return false; if (!target) { target = mAimObject.getPointer(); if (!target) return false; } if (_checkEnabled) { if (target->getTypeMask() & ShapeBaseObjectType) { ShapeBase *shapeBaseCheck = static_cast(target); if (shapeBaseCheck) if (shapeBaseCheck->getDamageState() != Enabled) return false; } else return false; } RayInfo rInfo; disableCollision(); S32 mountCount = target->getMountedObjectCount(); for (S32 i = 0; i < mountCount; i++) { target->getMountedObject(i)->disableCollision(); } Point3F checkPoint = getBoxCenter(); //getMuzzlePointAI(0, &checkPoint); //getBoxCenter(); bool hit = !gServerContainer.castRay(checkPoint, target->getBoxCenter(), TerrainObjectType | StaticShapeObjectType | StaticObjectType | PlayerObjectType | DynamicShapeObjectType, &rInfo); enableCollision(); for (S32 i = 0; i < mountCount; i++) { target->getMountedObject(i)->enableCollision(); } if (!hit) { //only return true if it's our intended target! S32 id = rInfo.object->getId(); if (id == target->getId()) return true;//<<<<<<<0----------------ALWAYS TRUE WHEN HIDING BEHIND OTHER PLAYERS :( } return false; } Any pointers on what I am doing wrong? I usually script this kinda thing but thought I'd try C++ instead.//=============================================//=============================================edited ... moments after posting ... :roll: DERPMy console function engineDefine was calling another LOS function and not my custom one here. :lol: PROBLEM WAS WITH MUPPET AT KEYBOARD Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.