I uses the nkast.Aether.Physics2D library for my game and now i makes Item class but i have problems:
const float ITEMS_RADIUS = 10;
public Item(World world, IItem item)
{
body = world.CreateCircle(ITEMS_RADIUS, 1, FVector2.Zero, BodyType.Dynamic);
this.item = item;
}
Is will be have a terrible optimization.
public void Update(World world)
{
world.Circlecast((fixture, point, normal, fraction) =>
{
if (fixture.Body.Tag is IMap)
{
velocity.X = 0;
velocity.Y *= 1f - normal.Y;
return 0;
}
if (fixture.Body.Tag is Player player)
{
player.Inventory.Add(item);
Remove();
}
return -1;
}, position, position + velocity, ITEMS_RADIUS);
}
It more looks like a normal realization.
But Aether does not have support the shaped raycasts me need to change physics engine or Aether have something for that?
I has try Box2D but there have the same.