You should be able to remove the collision response animator
here is my problem - how?!
if you have something liek this
Code: Select all
// find all meshes
core::array<scene::ISceneNode*> nodes;
smgr->getSceneNodesFromType(scene::ESNT_ANY, nodes);
for (u32 i=0; i < nodes.size(); ++i)
{
scene::ISceneNode* node = nodes[i];
scene::ITriangleSelector* selector = 0;
switch(node->getType())
{
case scene::ESNT_CUBE:
case scene::ESNT_ANIMATED_MESH:
// Because the selector won't animate with the mesh,
// and is only being used for camera collision, we'll just use an approximate
// bounding box instead of ((scene::IAnimatedMeshSceneNode*)node)->getMesh(0)
selector = smgr->createTriangleSelectorFromBoundingBox(node);
break;
case scene::ESNT_MESH:
case scene::ESNT_SPHERE: // Derived from IMeshSceneNode
selector = smgr->createTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
break;
case scene::ESNT_TERRAIN:
selector = smgr->createTerrainTriangleSelector((scene::ITerrainSceneNode*)node);
break;
case scene::ESNT_OCT_TREE:
selector = smgr->createOctTreeTriangleSelector(((scene::IMeshSceneNode*)node)->getMesh(), node);
break;
default:
// Don't create a selector for this node type
break;
}
if(selector)
{
// Add it to the meta selector, which will take a reference to it
meta->addTriangleSelector(selector);
// And drop my reference to it, so that the meta selector owns it.
selector->drop();
}
}
scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator( meta,
camera,
core::vector3df(3,6,3),
core::vector3df(0,-0.5,0),
core::vector3df( 0, 20, 0 ) );
meta->drop(); // I'm done with the meta selector now
camera->addAnimator(anim);
anim->drop(); // I'm done with the animator now
how do i get the animator anim from the camera? and even if i don't drop it ... i don't think it's a good idea to do not drop these animators. in a more complex game i don't want all the animators to be undropped.
and i don't find any getCollsionResponseAnimator function. i only found the getAnimators function from the scenenodes, but how can i find out, if it is my collresponseanimator i wish to edit?
edit:
k i now drop the collanimator at the end of the programe before i call device->drop() and inside the code i use this:
Code: Select all
// if collidiing with a windparticlesystem let the player fly
if( !HasNoCollision && windup->getTransformedBoundingBox().isPointInside( camera->getAbsolutePosition() ) )
{
HasNoCollision = true;
camera->removeAnimator( anim );
anim = smgr->createCollisionResponseAnimator( meta,
camera,
core::vector3df(3,6,3),
core::vector3df(0,50.0,0),
core::vector3df( 0, 20, 0 ) );
camera->addAnimator( anim );
}
else if( HasNoCollision )
{
HasNoCollision = false;
camera->removeAnimator( anim );
anim = smgr->createCollisionResponseAnimator( meta,
camera,
core::vector3df(3,6,3),
core::vector3df(0,-0.5,0),
core::vector3df( 0, 20, 0 ) );
camera->addAnimator( anim );
}
// if falling down somewhere reset player's startlocation
if( camera->getAbsolutePosition().Y <= -100 )
{
camera->removeAnimator( anim );
camera->setPosition( startlocvec );
camera->updateAbsolutePosition();
anim = smgr->createCollisionResponseAnimator( meta,
camera,
core::vector3df(3,6,3),
core::vector3df(0,-0.5,0),
core::vector3df( 0, 20, 0 ) );
camera->addAnimator( anim );
}
is this a good way to do it? i don't think so ?:D