collision detection on animated scene node problem.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
neusinger88
Posts: 1
Joined: Sun Oct 26, 2014 2:06 pm

collision detection on animated scene node problem.

Post by neusinger88 »

hello,
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.
    }
 
I create the ninja and setup collision response for the quake3 map as with the camera...

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.
    
    }
 
Then I update a fly straight animator within the game loop to follow the camera...

Code: Select all

 
scene::ISceneNodeAnimator* moveAnim = smgr->createFlyStraightAnimator(node->getPosition(), camera->getPosition(), 3500, true);
        if (moveAnim )
        {
            node->addAnimator(moveAnim );
            moveAnim ->drop();
        }
 
The character follows the camera fine but has no gravity applied to it and does not respond to collisions. I have spent time searching for the correct way of doing this but the docs seem to suggest that this is the correct way (same as the camera).
The function createCollisionResponseAnimator() doesnt seem to have had any effect on the ninja's node?
Any help would be much appreciated.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: collision detection on animated scene node problem.

Post by CuteAlien »

The problem is likely that animators can't be combined. You have to either to write your own animators (which maybe still can use build-in animators in some way) or use some completely different solution. The stuff in Irrlicht for collisions is good enough for a quick demo, but for a serious game you will mostly have to write your own stuff (and most people use then a physics engine for that).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply