1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 07:07:45 +00:00

fix bnpcs not navigating around obstacles

This commit is contained in:
NotAdam 2019-04-23 21:52:00 +10:00
parent 8002e88d10
commit e951a33d96

View file

@ -632,11 +632,24 @@ void Sapphire::World::Navi::NaviProvider::setMoveTarget( Entity::Chara& chara,
float vel[ 3 ]; float vel[ 3 ];
float p[ 3 ] = { endPos.x, endPos.y, endPos.z }; float p[ 3 ] = { endPos.x, endPos.y, endPos.z };
dtPolyRef ref;
auto status = m_naviMeshQuery->findNearestPoly( p, halfExtents, filter, &ref, nullptr );
if( !dtStatusSucceed( status ) )
{
Logger::error( "Failed to find nearest poly for Chara#{} for pos X: {} Y: {} Z: {}",
chara.getId(), endPos.x, endPos.y, endPos.z );
return;
}
const dtCrowdAgent* ag = m_pCrowd->getAgent( chara.getAgentId() ); const dtCrowdAgent* ag = m_pCrowd->getAgent( chara.getAgentId() );
if( ag && ag->active ) if( ag && ag->active )
{ {
calcVel( vel, ag->npos, p, ag->params.maxSpeed ); calcVel( vel, ag->npos, p, ag->params.maxSpeed );
m_pCrowd->requestMoveVelocity( chara.getAgentId(), vel ); //m_pCrowd->requestMoveVelocity( chara.getAgentId(), vel );
m_pCrowd->requestMoveTarget( chara.getAgentId(), ref, p );
} }
} }