is this possible to collide a NPC with walls? I used; "createTriangleSelectorFromBoundingBox", but it is not colliding

kindly help. my NPSs dissapear suddenly when they r near walls.
Code: Select all
/*
* function: Update
* params: None
* return: Nothing
* purpose: updates the cart's position
*/
void Cart::Update()
{
core::vector3df newpos;
float fAlpha = node->getRotation().X * DEGTORAD;
float fBeta = node->getRotation().Y * DEGTORAD;
float fDelta = FRAMEWORK->GetElapsed();
static core::vector3df direction;
static core::triangle3df triout;
static bool fallout = true;
static const scene::ISceneNode* outNode;
static core::vector3df collpos;
const float gravity = 100.0f*fDelta;
// reduce speed when player doesn't accelerate
if( fSpeed > 0 )
fSpeed = max( 0.0f, fSpeed - 10.0f * fDelta );
else if( fSpeed < 0 )
fSpeed = min( 0.0f, fSpeed + 10.0f * fDelta );
direction.X = fDelta * fSpeed * cos( fBeta ) * cos( fAlpha );
direction.Y = fDelta * fSpeed * sin( fAlpha ) - gravity;
direction.Z = fDelta * -fSpeed * cos( fAlpha ) * sin( fBeta );
newpos = smgr->getSceneCollisionManager()->getCollisionResultPosition( world, // triangleselector of world
node->getAbsolutePosition(), // position of node
core::vector3df( 10, 20, 10 ), // collellipsoid of node
direction, // direction force to move
triout, // collision triangle
collpos, // collision point
fallout, // ?
outNode, // collision node
0.01f ); // slide factor
node->setPosition( newpos );
} // end Update
Code: Select all
int main()
//...
list<NPC*> npcs;
npcs.push_back( new NPC() );
//...
while( gameisrunning )
{
list<NPC*>::iterator itnpc = npcs.first()
while( itnpc != npcs.empty() )
{
(*itnpc)->Update();
itnpc++;
}
beginScene( true, true );
// ...
endScene();
}
//...