Bug in Normal?? (Fixed)

Jun 13, 2009 at 1:52 PM

Hi i think (but am not sure) there is a bug in getting the normal of a collsion

  public bool PlayerColEvent(Geom geom1, Geom geom2, ContactList list)
        {
            Vector2 position = list[0].Normal;
            float angle = MathHelper.ToDegrees((float)Math.Atan2(position.Y, position.X));

            return true;
   
        }

 

Now when i debug the value collsions on the right or 0 left -180 up -90 and down (ground) 90.

However when i load a level from my map file ( i do this by using Clear() then loading all bodys and geoms). the normal is inverted as if *-1.

right is now -180 left 0 up 90 and ground -90?

is this a bug or am i missing something about the normal?

 

Jun 13, 2009 at 4:44 PM

This is probably because of a Feature ;) of Farseer Physics where the collison normal direction is dependant on the order of creation of the geoms. I'm not sure if there's a nice way to fix it. Being discussed here: http://farseerphysics.codeplex.com/Thread/View.aspx?ThreadId=51404

and there is an issue entry too: http://farseerphysics.codeplex.com/WorkItem/View.aspx?WorkItemId=22032

Jun 13, 2009 at 10:32 PM

Ah you were right thank you.

Now for the solution.

Basicly when i started the game i created the player first

When i loaded the game I created the object geoms first and the the player (this is the reason whey the noram was inverted)

The solution is always to created the players body and geom before anything else. hope this helps