Search Unity

Possible to check if interactive cloth is colliding?

Discussion in 'Scripting' started by unikum, Nov 6, 2010.

  1. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    Is it possible to somehow know if the cloth is colliding with something? I can't find anything in the class about this. For example if I throw a ball on the cloth I would like to know when it hits, or if it is colliding at the moment and so on. I've tried to check if the ball is colliding against something, but it doesn't pick up the cloth (it picks up the ground and all other with normal colliders on them).

    Anyone know if this is possible?
     
  2. Metal Head

    Metal Head

    Joined:
    Aug 14, 2010
    Posts:
    411
    I haven't even touched that component, but try assigning some sort of a collider, that will move with the cloth and make it a trigger. That's just a guess, I have never used it.
     
  3. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    I've tried adding colliders without success. I don't think it is possible to add a collider to move with the cloth. Since there already must be some sort of collider there (otherwise it wouldn't react to the ball already) it surely must be a way to access that one.

    Or could I detect it on the ball somehow? Since the cloth is responding and sending a force to the ball (collision response), can I see that in an event that a force is being added to the ball by the cloth object?
     
  4. defjr

    defjr

    Joined:
    Apr 27, 2009
    Posts:
    436
    Yeah, this is bugging me. I have a scene with a cloth banner and an inflated snowman cloth. I'm projecting snowballs in the scene like a shooting gallery and would like to add points to my score when I hit the snowman or banner.

    Any help with this? Andeeeeeeeeeeeeeee? ;)
     
  5. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Just a thought, but what if you did this: monitor the ball's velocity and if it slows down rapidly (and hasn't collided with anything) then consider that a collision with the cloth. Since the ball will register a collision with everything -but- the cloth you might be able to get the information you want from the other way around.

    I, on the other hand, would like to be able to -grab- a vertex of the cloth and pull it. I found that if I tweak the physics material of the grabbing object this helps, but it is still possible for the grabber to pass through the cloth. If anyone has any suggestions I'm all ears. ;)
     
  6. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58

    I'm back working on this project but still haven't managed to find a good way to solve this. Did you guys solve it in your projects?

    Please Unity Team can't you make us access an Interactive Cloth vertex to apply force and make the cloth register collisions (at the very least ray casts at least)? Or whatever it takes to be able to make sure that an object never can go through it, even in high speeds with low thickness on cloth.
     
  7. Ullukai

    Ullukai

    Joined:
    Aug 24, 2010
    Posts:
    746
    maybe use some other means to get it to do what you want it to do ? like make a trigger box to do it ?
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    cloths that would have real colliders would run like a crawl at best, mesh collider rebuilding already on 2k meshes leads to stutter, now try to do it each frame, you will will end on 3FPS

    interactive Cloths technically should themself interact with other rigidbody objects with colliders given you setup the physics right and make those objects move at reasonable speeds and have the cloth object detailed enough to react to it reasonably
     
  9. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    Isn't the problem that we can't get feedback from the cloth? Since it is already checking for collision, it shouldn't be any extra calculations just to tell us when and where it was hit for example? Because it seems like currently it is impossible to tell if the object has gone through the cloth or not. If a cloth should behave like a thin cloth, we can't just put a huge thickness to it because it wouldn't behave correctly. It might more often than not stop the fast object, but it would look horrible.

    Edit:

    Is there a specific reason why we can't find an interactive cloth with raycast for example? Would it for some reason be heavy on the cpu? Just wished we could set up the cloth to tell us whenever it was hit and where it was hit. It would solve everything.
     
    Last edited: Mar 19, 2011