Unity 3D: Automatic anchors for interactive cloth

04 Aug

In Unity 3D, if you wish to add interactive cloth in your scene, most probably you need bring in some anchor points, which instruct the cloth which site remains static and fixed. This is a tedious task, and the process may involve:

  • Add new GameObjects (Menu GameObject > Create Empty Object)
  • For each game object, add a collider component (Menu Component > Physics > Box Collider)
  • For each collider, specify the center and size of the collider
  • For each collider, specify the 3D location of collider, at which the cloth remains static
  • Make sure the collider overlaps/intersects with the cloth, otherwise, it won’t work. You might wish to calculate it carefully yourself!


What this post is trying to make, is to automatically introduce such anchor points to rectangular cloth (or rectangle mesh), and does all above programmatically, with configurable settings to add 1, 2, 3, and 4 anchors.


Usage: drag and associate the script (link below) to the cloth object in the scene hierarchy, and select which anchor (1, 2, 3, 4) you wish to add. That is it.


Now you don’t need to manually add colliders and even if your interactive cloth changes in location, rotation or even scaled! The script does all for you! Download the C# Script CornerAnchorForRectCloth.cs  and happy coding!

1 Comment

Posted by on August 4, 2013 in Unity 3d


Tags: , , , ,

One response to “Unity 3D: Automatic anchors for interactive cloth

  1. Pure Logic Edmonton

    April 7, 2014 at 10:45 am

    Hey, that was a very good write-up! Lots of high-quality details,
    I am excited that I located it.

    I am going to save your website! 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: