Question

I'm developing a platformer game with C# XNA and Farseer where the player should be able to swap gravity and run on the roof. Other objects affected by gravity will be there as well.

Is there any way I can control the gravity individually for each objects? i.e letting the player to have negative gravity and some boxes have normal gravity.

Thanks

Was it helpful?

Solution

I can't believe no one answered this for you yet. But if you do the following:

Body.GravityScale = -1.0f;

You simply give the body of the player a negative gravity by multiplying it with a scale of -1.0f. If your player consists out of multiple bodies like mine, you change all of their gravity scales to -1.0f. Learned something new myself, haha.

Hope this helps and I wasn't too late.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top