Exemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     m_Joint = GetComponent <AnchoredJoint2D>();
     m_Rigi  = GetComponent <Rigidbody2D>();
     m_Joint.connectedBody = m_ConnectRigi;
     m_Line = GameObject.Instantiate(m_LinePrefab.gameObject).GetComponent <ChainLine>();
     m_Line.transform.SetParent(transform);
     m_Line.transform.position = Vector3.zero;
     m_Line.SetChainLine(transform, m_Joint.connectedBody.gameObject.transform);
     m_ConnectRigi.freezeRotation = true;
 }
Exemplo n.º 2
0
        public void Break(Vector3 pos)
        {
            m_ConnectRigi.freezeRotation = false;
            Transform t = m_Joint.connectedBody.transform;

            m_Joint.connectedBody = null;
            Destroy(m_Line.gameObject);

            m_Line = GameObject.Instantiate(m_LinePrefab.gameObject).GetComponent <ChainLine>();
            m_Line.transform.SetParent(transform);
            m_Line.SetChainLine(transform, null);
            float dis = Vector2.Distance(pos, transform.position);

            m_Line.Break(dis, (pos - transform.position).normalized);

            m_Line = GameObject.Instantiate(m_LinePrefab.gameObject).GetComponent <ChainLine>();
            m_Line.transform.SetParent(t);
            m_Line.SetChainLine(t, null);
            dis = Vector2.Distance(pos, t.position);
            m_Line.Break(dis, (pos - t.transform.position).normalized);
        }