Search Unity

Collision between rigidbodies with large mass difference at high velocity has unexpected results

Discussion in 'Physics' started by RunSwimFly, Sep 11, 2018.

  1. RunSwimFly

    RunSwimFly

    Joined:
    Mar 2, 2011
    Posts:
    34
    I noticed while firing a machine run in my game at heavy vehicles that the vehicle motion was jittering noticeably. Having ruled out a frame rate drop I dug down into the physics.

    I've now reduced it to a test case with a large rigidbody sphere of 1,000 kg rolling at 30 metres per second being fired at by a succession of small rigidbody spheres of less than a microgram at a speed of 600 metres per second, at a rate of 20 times per second, and from a position just ahead of the sphere, ie opposing its motion.

    The velocity of the large sphere is essentially unaffected and yet the time it takes to cross a given distance is substantially increased. It appears that the collision process is resulting in direct positional displacements which have no effect on velocity and which appear to be largely independent of the masses of the two colliding bodies. I'm using discrete collision on the target and continuous dynamic on the projectile since without this the projectile passes straight through the target.

    The effect isn't particularly noticeable with my single shot weapons, only with the machine gun which is generating a new high speed collision on almost every second physics frame. At times the vehicle it is striking almost appears to stop as the positional displacements almost cancel out the vehicle's forward motion.

    Gameplay requires that I maintain a system with non zero flight time to target and also gravitational drop of the projectile. If I have to I can come up with a work around but that's going to require numerous other changes so I'd rather find some way to resolve this within the collision system.

    I'm using Unity 2018.2.0f2.
     
    Last edited: Sep 11, 2018
  2. RunSwimFly

    RunSwimFly

    Joined:
    Mar 2, 2011
    Posts:
    34
    I suspect this displacement is the collision solver making a final effort to stop colliders penetrating. I would have thought it would move objects in proportion to their mass but it appears that it doesn't take mass into account. In any case it's probably not usually noticeable except when velocities are extreme.

    I've come up with a solution of sorts by putting my high speed projectiles into a layer which ignores dynamic objects (while still colliding with and ricocheting off static geometry) and then raycasting each FixedUpdate against dynamic geometry and resolving collisions manually.
     
    Last edited: Sep 12, 2018