Modify Velocity Resulting from Collision Directly?
Posted: Tue Feb 07, 2012 1:23 pm
As always, thank you, Norbo, on behalf of all the hobbyist developers out there using your awesome engine!
I'm trying to create a pseudo-2D vehicle combat game using BEPU for the physics, and then drawing simple 2D sprites from a top-down perspective.
I'm having trouble controlling the behavior of objects to achieve this "pseudo-2D" effect. Basically, objects shouldn't interact in a way where one vertically overlaps another in any way. Under normal circumstances, this won't really happen - I've set the shapes of all the vehicles to just be simple boxes, both to ease the computational burden of collision detection (I assume), and to prevent sloped objects from riding up on each other. However, during high-speed collisions in particular, objects will often end partially on top of each other.
I've looked a little at the CharacterControllers, particularly the vertical motion constraint, but unless I'm doing something wrong, it seems that you can still jar an object out of position with the VerticalMotionConstraint, in the case of a high-speed collision. Position and orientation corrections can be pretty sloppy for my purposes - the user isn't seeing anything at all along the Y axis because of the top-down view and the fact that the only visual representation is a sprite drawn at a particular X, Z location. If something needed to be teleported back down to the ground, for example, it wouldn't be problematic because the user wouldn't notice it, as long as it happened really quickly and didn't muck up collision response.
Ideally, at the time of a verified collision I would like to remove the vertical element from the forces resulting from the collision, perhaps redirecting it in order to preserve the total force involved. I have explored the Pair and Contact objects, and can't seem to find an obvious way to get at this resulting response force. Is this even possible? I realize this approach may be wrong-headed or impossible, but it seemed the most elegant way to address this situation, since the only time I really need to manage vertical behavior is during/immediately after collisions.
For reference, these collisions are occurring at up to 100 units of speed, involving box-shaped objects sized about 1-2 units per side.
So, is it possible to modify an entity's collision response force directly in any way? Is there something else I'm missing here?
I'm trying to create a pseudo-2D vehicle combat game using BEPU for the physics, and then drawing simple 2D sprites from a top-down perspective.
I'm having trouble controlling the behavior of objects to achieve this "pseudo-2D" effect. Basically, objects shouldn't interact in a way where one vertically overlaps another in any way. Under normal circumstances, this won't really happen - I've set the shapes of all the vehicles to just be simple boxes, both to ease the computational burden of collision detection (I assume), and to prevent sloped objects from riding up on each other. However, during high-speed collisions in particular, objects will often end partially on top of each other.
I've looked a little at the CharacterControllers, particularly the vertical motion constraint, but unless I'm doing something wrong, it seems that you can still jar an object out of position with the VerticalMotionConstraint, in the case of a high-speed collision. Position and orientation corrections can be pretty sloppy for my purposes - the user isn't seeing anything at all along the Y axis because of the top-down view and the fact that the only visual representation is a sprite drawn at a particular X, Z location. If something needed to be teleported back down to the ground, for example, it wouldn't be problematic because the user wouldn't notice it, as long as it happened really quickly and didn't muck up collision response.
Ideally, at the time of a verified collision I would like to remove the vertical element from the forces resulting from the collision, perhaps redirecting it in order to preserve the total force involved. I have explored the Pair and Contact objects, and can't seem to find an obvious way to get at this resulting response force. Is this even possible? I realize this approach may be wrong-headed or impossible, but it seemed the most elegant way to address this situation, since the only time I really need to manage vertical behavior is during/immediately after collisions.
For reference, these collisions are occurring at up to 100 units of speed, involving box-shaped objects sized about 1-2 units per side.
So, is it possible to modify an entity's collision response force directly in any way? Is there something else I'm missing here?