Search Unity

Stiff soft body - plastic playing card

Discussion in 'Scripting' started by Pirs01, Sep 25, 2014.

  1. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    I'm trying to create user interactive plastic playing card.

    I tried Interactive Cloth however setting its Bending Stiffness to maximum value of 1 does not make it nearly stiff enough. It still acts like a cloth rather then a piece of plastic that should only bend when force applied and never under its own weight.

    I would appreciate suggestions of any approach that doesn't require implementing the physics from scratch.

    EDIT: The card should also spring back to its original form when force is no loner applied. Now that I think about it, the cloth approach never stood a chance? So the real issue here is not stiffness but rather elasticity.
     
    Last edited: Sep 25, 2014
  2. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    How about using a Bend or Bend Warp such as in this video. you could easily put a suitable tween on the values to spring a card back flat or whatever you need to do.
     
  3. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    Looks more like a work-around then solution. I was going for physics based simulation.
     
  4. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Using Physics for this is a terrible idea. It won't behave as you'd expect. Physics are more for emergent behaviours rather than a specific animation solution. It might be possible with a series of joints if you want to give it a try. Probably best off coding a custom solution for it.
     
  6. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    Seams I wasn't clear at all on what I am trying to do. It's not that I picked physics sim as a solution to my problem. The sim is the problem. I don't care for any animations. Physics sim is the end goal.

    I looked around for third party solutions to bring into Unity but can't find anything usefull. The BeamNG car crashing game seams to have all the physics I need. I think I read somwhere that the purpose of the project is to develop physics engine which will be made availbe in future but that doesn't seam to be the case at this point?
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Physics doesn't mean 'user interactive'. With Physynth, I created a single nice animation of the page turning, then matched the frame of animation (as time) to the rough movement and position of the finger. You can see it here:



    Now, in your case you probably want to bend up the corner of the card or something? you can easily just make 9 bones evenly distributed on a playing card with sufficient weights, and it would curl up and behave exactly as you'd like it. Furthermore, you can use a spline and more bones for more control over the end result.

    I'm saying I think physics are probably not the correct solution for this task. You haven't said how you'd like them to be interactive.
     
  8. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    I get what you're saying. My OP was hasty and not on point. The user interactivity isn't really important here. The user interaction was suppose to be through applying force to cards that are otherwise also interactive with environment. You're thinking card playing game where you can curl up your cards to see what they are. If that was all I needed the cards to do then what you and MikeUpchat suggested would work for me but that's just not it.

    It's a pretty small app I'm making and there doesn't seem to be any ready solution that suits me so I will probably have to reevaluate the entire concept.

    Thanks for all your time.
     
  9. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    I would say use bones, 9 placed throughout the cards, and align box colliders to the bones, with a bit of playing around you should be able to get a good approximation, depending on performance (you don't mention exactly what affect you're going for) you could just increase this until you get a good balance. The one thing is why you want it to flex? In real life it takes quite a reasonable force to bend a car, so if you are trying to simulate card collisions, there probably won't be any bending in real life.
     
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Right so force..... you mean stacking or flicking them? physx is ideal for such a thing but you might need to set the velocity and angular velocity directly.
     
  11. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    Cars and crashing is beyond the point. I was referring to (0:47):

    Look at the hood: it's a soft body but it's pretty stiff and most importantly it's elastic so it wobbles. In case of my plastic card there would be more elasticity, no permanent deformation or breaking points. I don't need it to tear or break - it should always tend to spring back to original form.

    Flicking, throwing, grabbing at various points and pushing / pulling / dragging / squeezing etc. The idea is that you can interact with it freely using touch screen so you can touch or grab it at multiple points simultaneously and do whatever.
     
  12. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    666
    reasonable force to bend a car... ha ha this was a type should have been "reasonable force to bend a card"

    Based on what you've said above, I'd use 9 bones, configure the joints and use a combination of the default PhysX with some scripting to better control the results, as you'll be really simulating the most playable result, as opposed to the most accurate.