deathbravo Posted February 28, 2016 Share Posted February 28, 2016 i tried to spawn 150 bots to fight. and the bots using setPathDestination to follow a path while performing patrol. I found they will stuck after killing the player and go back to a path node in a crowd. I read the aiplayer.cpp and found there is a OnStuck function has the ability to repath the bot.but the function plan path only considering static items in the map, if another bot blocked the way, the repath can't detour with bots.then I tried to add some code to see if our bot is stuck by other bot or player, then try to detour.the code is a modified version of the findcover.i am not sure if there is any cooked function to solve it and i missed it. if there is, i want to use the stock feature.struct BlockerSearch{ Player *blocker; U32 count; BlockerSearch() { count = 0; }};static void isBlockerAICallback(SceneObject *obj, void *key){ Player *p = dynamic_cast(obj); BlockerSearch *s = static_cast(key); s->count++; s->blocker = p;}bool AIPlayer::isBlockerAI(){ F32 width = mScaledBox.len_y(); Point3F forwardOffset; forwardOffset[0] = width/2.f; forwardOffset[1] = width/2.f; forwardOffset[2] = width/2.f; // Create a search state. BlockerSearch s; Box3F box(width /2.0f);//* 2.0f); Point3F center = getPosition(); const MatrixF& transform = getTransform(); Point3F forwardVector = transform.getForwardVector(); center = center + forwardVector + forwardOffset; box.setCenter(center); U32 mask = PlayerObjectType;// | AIObjectType; getContainer()->findObjects(box, mask, isBlockerAICallback, &s); //Con::errorf("searching found: (%u)",s.count ); if(s.blocker) { return true; } return false; }void AIPlayer::detorAI(){ F32 width = mScaledBox.len_y(); Point3F backOffset; backOffset[0] = width; backOffset[1] = width; backOffset[2] = width; Point3F center = getPosition(); const MatrixF& transform = getTransform(); Point3F forwardVector = transform.getForwardVector(); center = center - forwardVector - backOffset; setMoveDestination(center,false);}///////change the onStuck like this , it could back one step to make room for each othervoid AIPlayer::onStuck(){#ifdef TORQUE_NAVIGATION_ENABLED if(!mPathData.path.isNull()){ if( isBlockerAI()){ detorAI(); }else{ repath(); } }else#endif throwCallback("onMoveStuck");} Quote Link to comment Share on other sites More sharing options...
Azaezel Posted February 29, 2016 Share Posted February 29, 2016 For bots pathing around one another, Try a scheduled NavmeshUpdateAll(%this,true);Do ensure though you've got https://github.com/GarageGames/Torque3D/pull/1475/files rolled on in though unless you want your memory eaten alive. Quote Link to comment Share on other sites More sharing options...
deathbravo Posted February 29, 2016 Author Share Posted February 29, 2016 thanks Azaezelit seems I did 1 more stupid thing. 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.