- Home /
Cannot attach collider to interactive cloth
So, long story short, Below is a piece of code that user to work perfectly, and has since stopped working.It is in relation to InteractiveCloth, the funny part is that I am unable to attach or remove colliders, yet any other setting works.
It is made as a grappling hook, the below code is attached to a GrappleHook. The Ontrigger enter happens when it hits the top. A ball ( for now) shoots this grapple hook and once it hits a target, the InteractiveCloth collider is attached to the the Ball.( I do not have it attached to start with because at start the attachment holds nearly all the vertices ( making the cloth a lot less flexible).
SecondHook, is the initial second holding point for the cloth.
To be honest im not sure if im even doing this whole grappling hook thing properly, however please see the commented lines below to understand the point of failure. The strange part is that this worked perfectly, prior to placing the rope and the grappling hook ( which this script is attached to) under the same prefab ( previously the rope was a prefab made up of the Grappling hook as parent, and rope as child.
void OnTriggerEnter(Collider other)
{
rigidbody.isKinematic = true;
transform.parent = other.transform;
GameObject Ball = GameObject.Find("MainBall");
Transform RopeTransform = FingerEventsSamplePart2.ropeTransform;
print (RopeTransform);
//NExt 2 lines do not work
//RopeTransform.GetComponent<InteractiveCloth>().DetachFromCollider(SecondHook.collider);
RopeTransform.GetComponent<InteractiveCloth>().AttachToCollider(Ball.collider,false,true);
//Next line works perfectly.
RopeTransform.GetComponent<InteractiveCloth>().stretchingStiffness = 0.9f;
Destroy (SecondHook);
}
Really strange.. Can anyone guide me as to why this might be happening as im driving myself insane. I really appreciate any guidance.
Further Edit ----
I have attempted to move the script to the actual Ropeobject that has the Interactive cloth attached. Again I am unable to attach the ball.
The code below is attached to the rope object.
public void AttachColliders ( Collider ColliderObject)
{
transform.GetComponent<InteractiveCloth>().AttachToCollider(ColliderObject,false,true);
}
Uhm, can you explain what "works perfectly" means and what exactly "stopped working"?
This piece of code isn't really helpful. A lot external references ($$anonymous$$ainBall, FingerEventsSamplePart2, SecondHook) and we have no idea to what object this script is attached nor do we know with which object this object should collide / intersect.
We don't have your project. We only see the letters you wrote up there... Please edit your question and add more details. Ask specific questions. What doesn't work? What does work? What should it do? What have you already tried?
Hi Bunny,
Thank you, I have edited it with more information.
Unity in realtion to cloths is acting unpredicatbley, i change something small and it goes crazy. I have never had any experience like this in my years in Unity. Really frustrating. I threw 12 hours away trying to attach a cloth to a sphere. Ridiculous