简体   繁体   中英

Manage falling using rays in Irrlicht

In my game i'm currently working on, i only need very basic physics, so i don't want Newton, ODE, Bullet or similar. I basically only want to fall as long as no node (all equally sized blocks) is beneath me. I tried to send a ray from the camera and 100.0 units downwards. But it gives false positives.

selectedNode = NULL;

    //Falling
    ray.start = camera->getPosition();
    ray.end = vector3df(ray.start.X, ray.start.Y - 100.0f, ray.start.Z);
    selectedNode = collMan->getSceneNodeAndCollisionPointFromRay(ray, intersection, hitTriangle, PICKABLE);

    if(selectedNode)
    {
        std::cout << "ABOVE" << std::endl;
    }

I don't know why this malfunctions. I'm using Irrlicht, but that shouldn't really matter as i think the problem is realted to logics and not specifically to the renderer/engine.

irrlicht has source code available. I would try tracing into the code in debug mode and see what it's doing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM