Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

How can I make a 2D object has a soft/ squishy body?

Discussion in '2D' started by tommcmillan97, May 14, 2019.

  1. tommcmillan97

    tommcmillan97

    Joined:
    May 14, 2019
    Posts:
    1
    I'm making a 2D rope swing game and I want the player character to move about when hitting walls and moving etc. So the player character acts like a squishy ball. Something like in this video :
    .

    I'm relatively new to Unity and I'm not sure where to start with this.
     
  2. BunnyProductions

    BunnyProductions

    Joined:
    Apr 14, 2018
    Posts:
    236
    This seems rather difficult. Im assuming you need a mesh or something like a mesh, draw a "mesh collider" on it, and come up with a way of detecting which area of the mesh collides with what, then deforming accordingly.
     
  3. jeffreyschoch

    jeffreyschoch

    Joined:
    Jan 21, 2015
    Posts:
    2,457
    It isn't trivial. You can use physics colliders to detect collisions and use spring joints or math to keep them together for edge deformation, and then create a mesh from the collider positions.

    Luckily, many non-trivial things have been done before and you can base your work on them:

    Looking at some examples online:
    (Paid) https://assetstore.unity.com/packages/tools/physics/jelly-sprites-13327
    (Paid) https://assetstore.unity.com/packages/tools/physics/2d-soft-body-68777
    (Free) https://forum.unity.com/threads/jello-physics-soft-body-physics-free.225672/

    That free one is outdated and likely won't just work, but you can see how they created their solution.