Question by
Prosmatera · Jan 11, 2016 at 04:03 PM ·
collisionjointone
Creating only one joint
Hi guys i have script that creates joint on collision with another rigidbody ,but the problem is that on collision it creates multiple joints im not sure why, but i think its because the charachter have many childs
here is my script
using UnityEngine;
using System.Collections;
[DisallowMultipleComponent]
public class StickyObject : MonoBehaviour
{
void OnCollisionEnter(Collision c)
{
var joint = gameObject.AddComponent<FixedJoint>();
joint.connectedBody = c.rigidbody;
}
}
i tryed [DisallowMultipleComponent] but its not working on runtime i want it to create only one joint because i have destroy script which destroy the joint on click but when it creates multiple joints its not working anyone got any ideas how i can do this? Thank you
Comment
Did you ever find a solution to this? I was using " joint.enableCollision = false; " but its not consistent.