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:
parent
8002e88d10
commit
e951a33d96
1 changed files with 18 additions and 5 deletions
|
@ -632,11 +632,24 @@ void Sapphire::World::Navi::NaviProvider::setMoveTarget( Entity::Chara& chara,
|
|||
float vel[ 3 ];
|
||||
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() );
|
||||
if( ag && ag->active )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue