
Hi!
I need the information which side of my rectangle collides! How can i get it?
Thanks,
Michixxx



Check the contacts properties, there you should have the position where the collision has been detected.



I can't find there an option where you can get the information, which site of my rectangle(created with the bodyfactory) collides.



http://ianqvist.blogspot.de/2009/11/pseudoorientationinfarseerphysics.html ;)



Great! Thanks.
I am a beginnner and so its difficult to follow, although it looks like that its made with an older version of Farseer. I tried to import it in my project but it don't work.
Creation of body:
body = BodyFactory.CreateRectangle(world, (float)ConvertUnits.ToSimUnits(playertexture.Width), (float)ConvertUnits.ToSimUnits(playertexture.Height), 1f);
body.BodyType = BodyType.Dynamic;
body.Position = new Vector2(ConvertUnits.ToSimUnits(position.X), ConvertUnits.ToSimUnits(position.Y));
body.Mass = 1f;
body.OnCollision += new OnCollisionEventHandler(body_OnCollision);
On Collision:
bool body_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
Vector2 normal = contact[0].Normal; !!!Error!!!
//Needed to reverse the normal depending on the first created geometry.
if (fixtureA < fixtureB) !!!Error!!!
normal *= 1;
//Create rotation matrix
Matrix r = Matrix.CreateRotationZ( body.Rotation);
//Transform the normal using the rotation matrix
Vector2 rotatedVector = Vector2.Transform(normal, r);
//Use Atan2() to get the angle between the vector and the positive xaxis.
//Note that this function returns Pi to Pi
float radians = (float)Math.Atan2(rotatedVector.Y, rotatedVector.X);
//Lookup the angle in the intervals
_side = GetSideFromRadians(radians);
return true;
}



Hi Michixxx. Remove everything from the body_OnCollision method, just leave the "return true" (so you will have the collision reaction active).
Now, check the contact's variables properties. Right now I can't remember which one is, but one of them will give you the coordinates of the collision point.



I have already looked for a propetie that gives me the point of collision, but I haven't find one.



Sorry Michixxx, I'll have to check it on the code. Right now I'm at work, but as soon as I get home, I'll check it out for you. Cheers.



Have you found it?
Cheers



The Contact has a property called Manifold which contains the contact points information and the normal.



Have you actually tried that though? Every time I do it doesn't seem to give what I would think would be the right direction. I also haven't been able to figure out if it takes into account multiple contacts. If your square (in my case
a character) is walking on a floor and runs into the wall at the same time, then which does it give you?
You may have to use that onColission (or in my case, I was using the Begin Contact override function from the sensor test example) to make a list of each contact each frame. Then check each one in that list against whatever your question may be.

