Collison Problems

Sep 25, 2008 at 1:57 PM
First off, standard disclaimer, I'm a complete and utter newbie to C# and XNA. Truth be told, I'm a python guy.$0$0$0$0That out of the way, I've been messing around with XNA and Farseer as a way to learn C#, but I can't for the life of me seem to get collision working. Basically, what happens is I have a block, falling onto what's supposed to be the ground, and going straight through it. I did put them in different collision groups, and that changed nothing. (I tweaked it to have two blocks, they still both fall straight down).$0$0$0$0$0$0$0http://www.megaupload.com/?d=DSTHX2O0$0<textarea style="width: 320px; height: 5px; display: none;" id="texturl"></textarea>$0$0$0$0$0Here's the zip of my project file (I've got a cursorclass I was messing around with to make a little crosshair controled with the right stick of the 360. Feel free to ignore it, it's badly coded and doesn't do anything else. It's included on the off change it breaks something else). I'm using VC# 2008 Express, by the way.$0$0$0$0$0I tried looking through the demos, and I can't figure out what I'm doing wrong. Any suggestions would be very helpful.$0
Coordinator
Sep 25, 2008 at 6:00 PM
I would like to take a look at it, but I can't seem to download your project.

If you take a look at Demo 2 from the Demoes, that should be all that's needed for collisions to work.
Sep 26, 2008 at 3:48 AM
Odd. http://rapidshare.com/files/148449998/testplatformer.zip.html should work.$0$0$0$0Even just more-or less copying the code from Demo2 I can't seem to get it to work. The gravity-effected cubes fall straight through the ground object (Marked is_static so it doesn't move.)$0$0$0$0$0Upon poking the code further (And marking one of the boxes static), the boxes collide, but they still fly right through the ground body.$0
Coordinator
Sep 26, 2008 at 7:57 PM
Edited Sep 26, 2008 at 7:58 PM
This is an easy one to fix :)

Change

groundBody.Position =

new Vector2(400, 900);
to:
groundBody.Position =
new Vector2(400, 600);

Sorry it took so long to reply. I'm a busy man :)
By the way: Try using the PhysicsSimulatorView from the Farseer demos, they are really nice to debug situations like this.

 

Sep 27, 2008 at 11:09 AM
I appriciate the help, I'm patient ;).$0$0$0$0That helped, it got the Body/Geom where it needed to be, but what was really throwing me was that I was drawing the sprites in the wrong location. (Assuming the origin was in the upper left, when it gets redefined to the center of the texture). Oh well, can't learn without making mistakes.$0