Changing Mass in Farseer 3.0

Jul 19, 2010 at 6:48 AM
Edited Jul 19, 2010 at 3:43 PM

Hello I am attempting to port to 3.0 and it is working alright except that I cannot find anyway to change Mass in a body after its creation, and I find it strange that it isn't a setting at creation either.. For the game I am creating changing mass is definitely necessary. Is there anyway to change mass? I don't understand why it would be locked to it's relation of size...

Especially since it instantiates my character with apparently 512 mass.

Also collision appears to be kind of weird...

In 2.1 it appeared that if two things triggered, and one of the events returned false it would return false and end both collisions...  Say I have a platform that returns false if the player was under it, now the player will collide with it even though the platform is returning false. How do I go about fixing this??

Edit: Yeah, I am earnestly really confused on how Collision detection is working with regards to OnCollision now....

if (geom2.CollisionCategories == CollisionCategory.Cat1)

{

if (playerWasAbove)

return true;

return false;

}

I want the player to NOT fire the OnCollision at all if the platform returns false. Is this even possible? Although I also always wondered why do OnCollisions still fire even if the object is set to not collide with CollidesWith.

Edit: This has to be a bug or something, I made something straight up always return false in the OnCollision and the other object still fires it's OnCollision when colliding. Also Static Bodies are colliding with each other. Please tell me there is a way to set this straight.

Using 72561
Jul 19, 2010 at 3:56 PM
I would also like to know how to change the mass of an object. I can only find a setting for density.
Jul 19, 2010 at 4:02 PM
Although at this point I would more likely like to know about how to fix this collision nonesense!
Jul 19, 2010 at 7:49 PM
If it helps you out Apoxxle, I figured out the Mass thing. Looking through the source for FP3, you can find the Mass property on a Body. However it is read only, unless set internally by the engine itself. I did a "Find All References" on Mass to see where it got set. Turns out there is a few places it gets set but if you look at the ResetMassData() function on Body.cs you will see that the Mass is made up by an accumulation of the densities of Fixtures. Basically the density can be used as the Mass when you create objects with the Fixture factory. Hope this helps.
Jul 20, 2010 at 5:18 AM
Edited Jul 20, 2010 at 5:18 AM
Thanks for that DrLazer. As for Oncollision... I was unable to to get it working properly in any shape or form on the SVN I grabbed, but I grabbed an older one and when an OnCollision returns false the character will fall through, BUT the characters OnCollision is still fired. This is really weird and there has to be something up. I double checked on 2.1 and this is not how it used to be..
Jul 20, 2010 at 6:21 AM

Yeah, density is the key, I believe.  Changing the density of an object, given an set area (size), should increase the mass for you.

I remember setting on collision to false back when I was using FP2.01, and it would cause the collision not to happen (which would cause the two bodies to pass through one another).  I believe this is how it always has been.  Not sure if it changed in 2.1x, but that's how I remember it.  What are you trying to have happen?

Jul 20, 2010 at 4:15 PM

No that is how I want it. In 2.1 it is handling it right. I set a tile to return false and the character will fall through it AND his OnCollision will not fire.

In 3.0 however in the current distro, setting the OnCollision to false does nothing and both the tile and character's OnCollision will fire.

I set the 3.0 version back about a month and then the return false's would correctly have the character fall through BUT both OnCollisions would fire.
Is there anyway to stop that behavior in 3.0.

Jul 20, 2010 at 4:51 PM
Set the collision categories to none?