#Avian Physics
46066 messages · Page 47 of 47 (latest)
i think the issue might be somewhere else, can i somehow make colliders visible?
Yeah, PhysicsDebugPlugin
ok so my colliders aren't working properly
ok the issue is like. somewhere else. but idk where
as you can see, this is detecting a collision with this object, even though the collider is not even going in a direction where it'd collide
Do you know which entity it's colliding with?
Might give you a hint as to what's going on
Some thoughts just by looking:
- If the scale of your colliders is very small but the margins are large, they might be hitting the wall on either side of the player?
- Does the bullet entity have some kind of timeout?
- Is it possible they're colliding with the player and despawning on a delay
Hard to diagnose just by looking looking though...
It is colliding with the chunk I'm on (the terminal behind is the one i'm using to debug this)
it might be the margins tho
the bullet entity has no timeouts
My guess is margins but it'd be a weird one
yeah which is why it'd be weird if it was margins :/
this one doesn't make a lot of sense to me, it almost looks like it's hitting the border of the collider as though it was still there even after despawning? But that wouldn't make sense because simple shapes do have solidity, it's only collision meshes which don't
importantly, i can move through the borders the ball can't cross, and it's only from certain angles that this happens
it almost feels like maybe the way avian determines collisions with rectangle shapes is wrong?
or with circle shapes
ok it's definitely specifically collisions detected by Collisions
the object does not bounce like this
(i removed the self destruction thingy and it collides with things that it doesn't bounce on)
(it has a low restitution)
(high? one of the two)
(whichever is bouncy. can't recall)
i will check what's up with collision events
That's weird I was always under the impression that Collisions was pretty much the lowest-level you can get
same issue with collisionstarted messages
Afraid this is outside my ability :/ I wonder if it is a bug but it's one I've never seen before
same issue with the CollidingEntities component
can you try setting SpeculativeMargin::ZERO on the bullet?
it's possible it's a ghost collision caused by speculative collision, as described here
https://docs.rs/avian2d/latest/avian2d/dynamics/ccd/index.html#caveats-of-speculative-collision
you could also filter the collisions by penetration depth for the purposes of despawning, i.e. filter out contacts where find_deepest_contact returns a point where penetration < 0.0 (meaning the shapes are actually separated)
contacts are not always necessarily actually touching if you have speculative collision enabled
i'll just tuck that away for later and for next time this comes up...
i'll perform some more tests to make sure it wasn't a fluke
Well the upper bound for it is currently infinite, but it's always clamped based on the velocity of the body, so it's essentially the distance that the body would move during the next timestep, given the current velocity
the idea with speculative collision is that it lets the solver "predict" contacts before they happen rather than allowing bodies to clip into/through walls and such, but it can cause these sorts of ghost collisions at high speeds
setting SpeculativeMargin lets you specify an upper bound for that margin or even disable speculative collision entirely by setting it to zero
the Bepu physics engine has the same, and also defaults to it being infinite IIRC
however I'd like to try Box2D's approach to continuous collision at some point, I believe it's a bit smarter about this and not quite as prone to ghost collisions
@vestal minnow u free rn for quick question?
I was planning to have 2 different physics tick rate in my world
as a part of this idea:
- anything related to network and players run at 64hz
- anything that's related to rest of the world - 20hz.
physics for players run at 64hz, and for everything else - 20hz.
thinking of using client side prediction with entity interpolation logic to smoothen stuff out and make it compatible with higher refresh rates
but avian only supports single tick rate for a world
thinking of having custom cheap logic for non players, so NPCs/zombies etc run through cheap simulations
I am making a simple brick-breaker style game, and it seems the ball is gaining energy over time. I have all the colliders set up with
Restitution::PERFECTLY_ELASTIC,
Friction::ZERO,
but there is a consistent energy gain. After a few dozen collisions, the ball moves so fast it can't be seen and basically clears the remaining blocks instantly from how fast it is moving
I suspect this is caused by one of two things:
a) brick colliders "touching". The bricks have no space between them and the rectangular colliders match. Possibly the ball is "hitting" two bricks at once in an edge case and momentum is not computed properly
b) The brick colliders are removed when a collision is detected. Maybe I need to defer the removal until the collision is no longer happening?
Does anyone have ideas/thoughts on this?
try it with just one brick that doesn't vanish?
so, this isn't really a solution to the problem, but making the ball either a kinetic body might not be a bad idea. This is the kind of situation where you end up fighting the dynamic rigidbody behavior.
honestly if you're in 2d making breakout and a dynamic body doesn't work it might just be easier to model it with aabbs and nothing else
is there any fork or branch of avian out there that works with bevy 0.19.0-rc.2?
#physics-dev message
yeah I found that one, but that is bevy main, not the rc which some of my other deps do already use. I'm in the process of doing the work myself, and will probably just put it up as a draft PR soon so others can use it too!
oh, thanks! just pointing to that because I just saw it, some folks don't know about #physics-dev
what's the current status of 0.19 port in avian? is there a functional branch i could use?
okay maybe if i just read few messages up :D
you could use this, I think its functional now: https://github.com/avianphysics/avian/pull/991
let me know if something is broken. I am aware the examples still need updating, I dont quite have time to do that right now though. And what the PR does now is enough to use avian at least.
thanks! i'll get back to you soon, i'm not on my linux right now
yeah no rush, I'm about to try it in my own project as well
i can set .with_max_force(20_000.0), and its somehow fixes kinda