Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Moving Prefab with Interactive Cloth in script

Discussion in 'Editor & General Support' started by obviousjim, Feb 28, 2011.

  1. obviousjim

    obviousjim

    Joined:
    Oct 11, 2009
    Posts:
    28
    hey all,

    we're doing a project that has flags on boats. When we create a new boat we want to put a flag on the back sometimes. To do this we made some prefabs with interactive cloth, then when a new boat is made we put the flag on the boat.

    That's the idea anyway - but we're running into a few weird issues with this...

    First, if we instantiate the prefab using Instantiate() the cloth plane just instantly falls off..even though it's touching the collider

    Then we tried having the flags already in the scene and just repositioning their transform to the boat. When we move them the flag cloth just drops off as soon as we set transform.position in the script.

    So then we decided to move them *slowly* using Lerping. This actually sort of worked - but when then there seems to be a weird bug where the flag material is invisible in the Game view until you click back and forth in the Scene. Perhaps because it starts off screen? The magic invisible material bug also shows up in the player.

    Has anyone encountered these problems and know how to work with them?

    Unfortunately using Skinned Cloth doesn't work for the effect we are trying to get...

    thanks!
     
    Last edited: Feb 28, 2011
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Are you using the AttachToCollider function on the cloth after instantiating it and positioning it on the "flagpole" collider?
     
  3. obviousjim

    obviousjim

    Joined:
    Oct 11, 2009
    Posts:
    28
    ah-hah! that worked great. I was calling attach to collider *before* thinking that we needed to attach it and then move it, but that makes sense!

    Makes the puppet show we were doing before seem pretty silly. Thanks Andeeee
     
  4. jytu

    jytu

    Joined:
    Nov 4, 2009
    Posts:
    22
    It works for me too but my fps drops down dramatically while I'm moving the clothes :(

    Do you have any ideas why?
     
  5. jytu

    jytu

    Joined:
    Nov 4, 2009
    Posts:
    22
    I use Lerp to move the collider in a Coroutine. Maybe that's the problem?