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.
精彩评论