Thanks alot,
I have used Solution 1) since it was pretty easy to shift the drawn picture as well.
Thanks alot,
I have used Solution 1) since it was pretty easy to shift the drawn picture as well.
I’m curious if anyone has used this engine for commercial games? Has it worked out well? Seems like a great tool.
Hi @holyfuzz, what you’re describing sounds very similar to some performance issues I’ve found in my testing. Would you be willing to share your modified BroadPhase code? I’m very interested in testing it out and seeing if it optimizes my game as you’re saying it did yours. You can check out my thread on the matter here: https://github.com/tainicom/Aether.Physics2D/issues/61
Andrew
Happy to share! (With the caveat that my fork of Farseer has a bunch of other changes to it as well that I’ve made over many years and don’t remember very well, so isolating the broad-phase changes may or may not be easy.)
Send me an email and I’ll send you a zip of my Farseer code. (Unfortunately my Farseer code is part of my closed-source engine, so I don’t have a Git repo I can easily share with you.)
It was definitely tricky to get the broad-phase changes working, what with all the coordinate system conversions that need to happen with all the collisions and raycasts, but I think it’s working very well now. I’ve had this code live in my game for about half a year now with no reported issues, and the performance improvements for my particular game were enormous.
Hi,
is it possible to configure gravity dynamically? So that you have more gravity further down, for example, or that the bodies are not pulled in one direction, but to a point?
You can implement whatever effect you want by applying a force on bodies on each frame/step.
First you need to disable the build-in gravity. Set World.Gravity
to [0;0] or Body.IgnoreGravity = true
for individual bodies. Then iterate all bodies in World.BodyList
and apply your own force.
See the SensorTest, GravityControllerTest
, BuoyancyController
and SimpleWindForce
in TestBed app.
Aether.Physics2D v1.4
In this Release:
Github:
Nuget:
Is it possible to add more collision categories to Aether Physics2D? 31 categories are not enough if you have more than 31 different types of objects/bodies in a game.
Rectangle.SetCollisionCategories(Category.Cat31);
If categories are not sufficient then you have to use the more flexible callbacks (like ContactManager.ContactFilter for example) and disable the new contacts.
Example:
At the beginning, the ball cannot collide with the ground and it can move through the ground, but when the two bodies are separating, then the ball can collide with the ground and the ball cannot move again through the ground.
How can I use AfterCollision?
I get this error message:
No overload for ‘Ball_AfterCollision’ matches delegate ‘AfterCollisionEventHandler’
Body Ball, ground;
ground = world.CreateEdge(new Vector2(-4.0f, 5.0f), new Vector2(20.0f, 5.0f));
Ball = world.CreateCircle(0.25f, 1.0f);
Ball.BodyType = BodyType.Dynamic;
Ball.Position = new Vector2(10.4f, -1.0f);
Ball.SetRestitution(0.3f);
Ball.SetCollisionCategories(Category.Cat2);
Ball.FixtureList[0].BeforeCollision = Ball_BeforeCollision;
Ball.FixtureList[0].AfterCollision = Ball_AfterCollision;
bool Ball_BeforeCollision(Fixture sender, Fixture other)
{
if (other == ground.FixtureList[0])
return false;
return true;
}
bool Ball_AfterCollision(Fixture sender, Fixture other)
{
if (other == ground.FixtureList[0])
return true;
return true;
}
@nkast Amazing work on this library!
I’m trying to port it to a different language (Xojo) but there’s one part of the source code that I can’t work out (it may be because C# is not my main language).
In Dynamics/Contacts/Contact.cs
there are references to what looks like a global Collision
object but I can’t find it’s definition. For instance, on line 405, in the switch:
case ContactType.Polygon:
Collision.Collision.CollidePolygons(ref manifold, (PolygonShape)FixtureA.Shape, ref transformA, (PolygonShape)FixtureB.Shape, ref transformB);
break;
I have already ported the Collision
class and its CollidePolygons
static method but why is this code not just:
Collision.CollidePolygons(ref manifold, (PolygonShape)FixtureA.Shape, ref transformA, (PolygonShape)FixtureB.Shape, ref transformB);
Instead of:
Collision.Collision.CollidePolygons(ref manifold, (PolygonShape)FixtureA.Shape, ref transformA, (PolygonShape)FixtureB.Shape, ref transformB);
Essentially, why are there two Collision
calls?
Any help is greatly appreciated.
Thanks so much! I need this, Farseer was deprecated.
Hi, there a question. Is for your engine something like documentation, i started to learn monogame newly and want to get something bigger that only forum.
Aether.Physics2D v1.5
In this Release:
From v1.5 the nuget package Aether.Physics2D
contain the standalone library with no dependencies to 3rd party math libraries (microsoft.XNA.Framework.Vector2).
Standalone: https://www.nuget.org/packages/Aether.Physics2D
The monogame based library and the monogame based diagnostics were moved to Aether.Physics2D.MG
and Aether.Physics2D.Diagnostics.MG
. To upgrade to the new version please replace the nuget reference with the new one. Sorry for this inconvenience.
https://www.nuget.org/packages/Aether.Physics2D.MG
https://www.nuget.org/packages/Aether.Physics2D.Diagnostics.MG
Aether.Physics2D v1.6
In this Release:
Standalone:
https://www.nuget.org/packages/Aether.Physics2D
Monogame:
https://www.nuget.org/packages/Aether.Physics2D.MG
https://www.nuget.org/packages/Aether.Physics2D.Diagnostics.MG
Documentation:
https://tainicom.github.io/Aether.Physics2D/
Discord: https://discord.gg/95nPEjZ6mu
Aether.Physics2D v1.7
In this Release:
Standalone:
https://www.nuget.org/packages/Aether.Physics2D
Monogame:
https://www.nuget.org/packages/Aether.Physics2D.MG
https://www.nuget.org/packages/Aether.Physics2D.Diagnostics.MG
Documentation:
https://tainicom.github.io/Aether.Physics2D/
Discord: https://discord.gg/95nPEjZ6mu
Hey @nkast .
I´ve started to implement Aether.Physics2D on my game after dabbling a bit with Farseer. I have a quick question that is confusing me a little bit:
The ConvertUnits was removed. An orthographic camera (View&Projection) is preferred for rendering your Physics world.
You can find ConvertUnits here and copy it in your project if you find it useful.
Without the ConvertUnits the default display units to sim Ratio is 100f
? because I used to set it to 64 pixels per meter due the size of my sprites.
Sorry if my question is dumb, I´m just getting used to implementing the engine and I’m having some troubles setting the sizes of the bodies to match the sprites sizes, resulting in wierd collisions probably due to bodies overlapping
The library doesn’t do any conversion. ConvertUnits was simply a multiplication with a factor.
This is something you do in the draw method, and you choose your own units to sim, or dpi.
Preferably you can incorporate this into your camera view matrix if you implement resolution independent rendering.
Does anyone know a way to increase the maximum velocity (seems to be 120) of bodies? I’d take a hit on precision if I could increase velocity. Currently I have two possible workarounds, both of which are ugly:
Any ideas?
You could if you build it from source,
but I don’t suggest it because of floating precision errors when you multiply something very large (bodies expressed directly in pixels) with something very small (time).
At the end, you still need to multiply the scale factor in forces/velocities.
For example, gravity has to be 128 times larger if your dpi is 128.
Splitting the steps indroduces more precision errors, because the time is smaller.
The right way is to express the simulation in KMS, which is what the library was tuned for, and scale it up for drawing.