1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    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?