I have a problem with my physic on my first game and I would like to have some feedbacks or ideas coming from the experienced ones :).
I'm just going to explain the situation in details because its kinda complicated... I apologize in advance for the bad spelling since my English is not perfect yet!
Alright so I am developing my first game with 2 of my friends at the university and I am the one who has to implement the physic on the game.
The game is a 2d side scrolling with an isometric view. So since we were completely clueless about physics we chose to pick farseer for our physic engine. At first it seemed like a good idea and farseer works really fine for 2d games.
Now after I incorporated the physic, we made a few decisions for the game that kinda complicated things out for physic.
At first the isometric view was designed to be only 2d with the impression of 3d, but we decided to do it in 3d (except that we use XNA sprite batches with a isometric camera. That part works really well but since we are now in a 3d world, the physic is kind
We then had a nice idea of doing it with physic layers. Let me explain what I mean by that :
There are 5 different layers in which the player can move, depending on his coordinate in Z, the player will collide only with the physical bodies that are on the same layer as him.
So for example if there is a box in layer 1, the physical body is a square for every Z in that layer to give the impression that the player is really colliding with the box.
the layers are managed simply with the collision categories in farseer. When the player change layer, his collision category change corresponding to this layer.
So that fixed our problem to incorporate 2d physic in 3d...
The problem is now. If I go back to the example of the box above, I don't have any problems when I collide in X or Y, but if I move in the z plane it does not work.
Now, I know its normal because farseer was not made to manage Z collisions... now I am trying to figure out a way to fix this problem as well.
so to simulate the z collision, I made 2 farseer physic bodies that verify collision within the layers above and atop the moving objects. With CollisionResponseEnabled at false those bodies always follow the moving object without colliding but while still verifying
collisions. (then if collision was true, I would prevent the moving object from moving to the layer where there is the collision (for the given position))At first it sounded like a good idea, but the collide function always seems to return a collision with
something which kinda screw-up my plan.
So since all physic bodies are on the same x,y (which mean they are virtually all at the same x,y for a given z) I want to know something :
does the collide function verify the collisions within different categories? if yes, well I would need to know if there is a way to verify collisions only within a collision category (for example, I want to verify the collisions that are made only within
a specific category, is there a way to do that?)
also, if I can't know on which category my object collides with, is there a way to know with which object my object is colliding? (this way I can go and find the collision category)
thats about it for now, if anyone can help, it would be really appreciated. Thanks for reading, thank you.
Mar 19, 2010 at 7:40 PM
Edited Mar 19, 2010 at 7:53 PM
Sounds like you need a 3D physics engine. The only way I can think of is to have another PhysicSimulator for the top down view of the world. I would bet that using a 3D physics engine will be much easier and faster.
nvm, i was able to do it myself and some help with the people I work with with the OnCollision and OnSeparation methods.
thank you anyway!