Search Unity

Fast moving collider = pushing objects through floor

Discussion in 'Physics' started by joshcamas, Jan 10, 2019.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    I'm building a large monster that attacks their victims by smashing their body onto them.

    However, unsurprisingly, since it's body is a collider, it causes whatever object underneath them to be pushed through the ground. (since the attack is so fast)

    Sadly I do indeed need collision on the monster :(

    Any ideas? I'm hoping to not need to sacrifice the game play for physics issues if possible
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I assume you've already tried setting the Collision Detection Mode to "Continuous Dynamic". If not, that's an easy place to start to see if the performance is improved.

    Is your attack occurring via an animation? If so, is the monster's Animator's Update Mode set to "Update Physics"?

    One approach might be to turn the collider into a trigger collider during the attack. Then, instead of applying force via the collider, you'd check for Trigger Enter on the trigger, and do something interesting (like kill the player, push an object away, etc).

    I guess another important question is: What should happen when your monster squashes something? Should something different happen depending on what gets squashed?
     
    SparrowGS, xVergilx and joshcamas like this.
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Alternatively, add a collider beneath the ground to "guide" where the engine should depenetrate the collision. Or increase the volume of existing one.


    What ground collider do you use btw?
     
    SparrowGS likes this.
  4. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,278
    I set the update mode to Update Physics, and this fixed the issue! I was using the terrain collider btw
     
    dgoyette likes this.