I am currently messing around with 2D buoyancy effectors for a sprite based game. I have made a swimming animation for the player object that changes the size of the collider boundaries frame by frame. It seems as though the buoyancy calculation in Unity finds the density of the object using Rigidbody.mass / Collider2D.size (or something like that). I guess this makes sense for most cases, but because of the animation this constantly changes the density for the player object causing the player to weirdly float or sink with each animation frame. The "real" size of the object should not actually be changing so it would be nice if I could simply tell Unity to use a constant mass and density and just have it ignore the size of the collider. I looked at Rigidbody2D.useAutoMass, but that would change the object's mass with each frame, which is also not what I want. Is there a way to do this, or else a better way to handle buoyancy for an animated object?
↧