I am a newbie to 3d game development but have a reasonable knowledge of c++.
After following tutorial no.7 on collision detection i decided to expand on it and have one of the characters follow the position of the camera (no problems here).
Then after getting the character to follow the camera i wanted to stop the character from moving through the walls and floor, and apply gravity to it.
The tutorial implies that the same function createCollisionResponseAnimator() should apply to any scene node?
First i add a triangle selector to the quake 3 map node...
Code: Select all
// The Quake mesh is pickable, but doesn't get highlighted.
if (q3levelmesh)
q3node = smgr->addOctreeSceneNode(q3levelmesh->getMesh(0), 0, IDFlag_IsPickable);
//create a triangle selector
scene::ITriangleSelector* selector = 0;
if (q3node)
{
q3node->setPosition(core::vector3df(-1350,-130,-1400));
selector = smgr->createOctreeTriangleSelector(
q3node->getMesh(), q3node, 128);
q3node->setTriangleSelector(selector);
// We're not done with this selector yet, so don't drop it.
}
Code: Select all
node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("../../media/ninja.b3d"),
0, IDFlag_IsPickable | IDFlag_IsHighlightable);
scene::ISceneNodeAnimatorCollisionResponse* anim = smgr->createCollisionResponseAnimator(
q3node->getTriangleSelector(), node, core::vector3df(30,50,30),
core::vector3df(0,-10,0), core::vector3df(0,30,0));
node->addAnimator(anim);
anim->drop(); // And likewise, drop the animator when we're done referring to it.
}
Code: Select all
scene::ISceneNodeAnimator* moveAnim = smgr->createFlyStraightAnimator(node->getPosition(), camera->getPosition(), 3500, true);
if (moveAnim )
{
node->addAnimator(moveAnim );
moveAnim ->drop();
}
The function createCollisionResponseAnimator() doesnt seem to have had any effect on the ninja's node?
Any help would be much appreciated.