Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by OmegaVemon · Nov 22, 2010 at 05:30 AM · gameobjectsmodelsclothattach

"Attach" cloth.

Let's say I want to make a flag.

I make a stick, which is a cube with a long height. Then I make a cloth object. Technically, I want to somehow attach the cloth object to the cube object, simulating a flag... but I can't find a way to efficiently achieve such =/

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
8
Best Answer

Answer by jonas-echterhoff · Nov 22, 2010 at 11:00 AM

What you need to do is to add a collider to the object you want to attach the cloth to. Make sure the cloth mesh and the collider overlap in some vertices. Then, in the cloth component, expand the "Attached Colliders" field, and set the size to 1 (or how man colliders you want to attach). Expand "Element 0" and Drag the collider object to the "Collider" slot.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image OmegaVemon · Nov 22, 2010 at 06:08 PM 0
Share

Thanks! Works perfectly!

avatar image Proclyon · Nov 22, 2010 at 06:39 PM 0
Share

oh so that's what u meant :o, good thing jonas knew then :) Wouldn't have known that.

avatar image
3

Answer by Proclyon · Nov 22, 2010 at 08:01 AM

Hook up the object as a child to the parent ( Drop the "flag cloth" object onto the pole object. An action you can perform in the editor tab named "hierarchy" when your scene and project are loaded.

What happens now is that when you change the pole, the same will happen to the "flag cloth". You can specifically add effects or other to child which will not effect the parent (like wind blowing through it) if you want for the future.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image OmegaVemon · Nov 22, 2010 at 06:08 PM 0
Share

The cloth might be the pole's child, but it still won't achieve an "attached" effect.

avatar image
1

Answer by sfusco · Mar 17, 2015 at 08:29 AM

In Unity 5 this changed. Here is what I ended up doing to create my flag.

  • create an empty game object to hold the parts

  • Add a child cylinder as the pole

  • Add a child cloth as the flag

  • Add a mesh renderer to the cloth

  • configure the renderer to have two materials, one normal, one with inverted normals

  • click 'Edit Constraints'

  • change to 'Paint' mode

  • select vertices on the mesh that you want constrained, for a flag, this is the full edge along the pole probably

  • configure some forces to make the flag flap

Images of the process above


Custom shaders I am using on the materials


 Shader "Custom/NoBackfaceCulling" {
     Properties {
         _MainTex ("Base (RGB)", 2D) = "white" {}
     }
     SubShader {
         Tags { "RenderType"="Opaque" }
         LOD 200
         Cull Off
         
         CGPROGRAM
         #pragma surface surf Lambert
 
         sampler2D _MainTex;
 
         struct Input {
             float2 uv_MainTex;
         };
 
         void surf (Input IN, inout SurfaceOutput o) {
             half4 c = tex2D (_MainTex, IN.uv_MainTex);
             o.Albedo = c.rgb;
             o.Alpha = c.a;
         }
         ENDCG
     } 
     FallBack "Diffuse"
 }



 Shader "Custom/InvertedNormals" {
     Properties {
         _Color ("Main Color", Color) = (1,1,1,1)
         _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
         _BumpMap ("Normalmap", 2D) = "bump" {}
         _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
     }
     SubShader {
         Tags {"IgnoreProjector"="True" "RenderType"="TransparentCutout"}
         LOD 300
         Cull Front
             
         CGPROGRAM
         #pragma surface surf Lambert alphatest:_Cutoff
 
         sampler2D _MainTex;
         sampler2D _BumpMap;
         float4 _Color;
 
         struct Input {
             float2 uv_MainTex;
             float2 uv_BumpMap;
         };
 
         void surf (Input IN, inout SurfaceOutput o) {
             half4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
             o.Albedo = c.rgb;
             o.Alpha = c.a;
             o.Normal = -UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
         }
         ENDCG
     } 
     FallBack "Diffuse"
 }



Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

Binding Cloth to hang from ceiling 2 Answers

Animations: Ist it possible to attach two gameobjects and animate them? 1 Answer

Making a Cloak using the Cloth GameObject 2 Answers

Should I have a root bone? 0 Answers

What happened to the mesh? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges