This is my first post on this forum so go easy on me
I have a static world that consists of btBvhTriangleMeshShapes and btStaticPlaneShapes. Currently everything works fine, but there's no "floating": what I'd like to implement is a moving object that floats above one of the static objects, much like magnets repel each other or like (well, not much like) a helicopter gets more lift when it's near to the ground.
Is it sensible to implement the above by:
- creating an object that represents the surface that causes the "float". This object would not be rendered visually but it would only be used for physics calculations
- multiple rays would be cast from the floating object's underside and then with the magic of pseudo code I would:
Code: Select all
for all rays {
if(ray hits a surface which causes floating){
length=length from ray's starting position to collision point
force=(MAX_FLOAT_FORCE-length)*ADJUSTMENT; // so force is stronger when closer to the surface
if(force>0) { // object is close enough for the force to "reach it"
apply force to moving object (to the place where the ray started) to the direction of the surface's normal
}
}
}
....or is there a completely different approach that would be better suited for my needs? I haven't looked at ray casting at all yet - I took a quick look at Raytracer.cpp but haven't "digested" it yet - so is what I suggest above even feasible with bullet physics? All kinds of suggestions and comments are more than welcome!