I’m having trouble automatically moving a box away from the corner of a room (so it is no longer colliding with any walls). I have a box in the corner, which is initially not actually colliding with any walls but practically touching them. However, if I rotate the box, it’s bounding box increases in size, and so it intersects with both walls. I want to move it away enough so it is no longer colliding. However, I only have the co-ords of the centre of the walls (since I’m using bounding boxes), and if I move the box away from the wall using this co-ord, it actually moves it further into the other wall (and vice versa). Eventually it gets pushed out the other side through both walls!
Unfortunately, collisions between bounding boxes don’t return the actual collision point or normal so I can’t use that. Is there any way to solve this?
I’ve got my own simple physics engine; nothing special, but it handles collisions and gravity and bouncing. I’m just having trouble moving spatials back when they overlap. I think my solution will be to use non-rotating boundingboxes.
I run a headless server, mainly so I can run the same code on the client and the server. Seems to work well enough, though is there a better way?
Usually treating Spatials as game objects will end up collapsing under its own weight at some point. You pull in a lot of baggage with a Spatial that is unneeded in a game object and its too tempting to modify things directly, etc.
…especially in a networked game, it usually ends up being 1000x better to have real game objects and let the Spatials just be the view-side expression of those.
FWIW, I have just come up with a solution to this: taking each axis in turn, if the box’s bounding box is within the boundingbox of the wall, then don’t move the box on that axis. Otherwise, move the box away from the wall along that axis.
Regarding your suggestion to only use JME on the client, I’ll make a note, but it will mean a lot of refactoring, so maybe I’ll do it in version 2 of my engine
Just re-read your original post - you’re probably ok, actually. I thought you were referring to doing this as part of dynamic movement, not static position. If you were doing something like this as the box is dynamically colliding with the wall, you’d have to be careful regarding the point and angle of contact with the wall to correctly calculate the direction that the box will rebound towards. Just moving it out of the wall would lose that information and you wouldn’t get a correct rebound - hence my earlier post about physically incorrect motion.