示例#1
0
    // Use this for initialization
    IEnumerator Start()
    {
        for (int i = 0; i < ropeCount; ++i)
        {
            Transform ropeTrans = new GameObject("Rope" + i).transform;
            ropeTrans.parent        = transform;
            ropeTrans.localPosition = Vector3.zero;
            B2DBody prev = ground;
            for (int j = 0; j < nodeCount; ++j)
            {
                B2DRevoluteJoint rj = (B2DRevoluteJoint)Instantiate(jointPref);
                rj.transform.parent        = ropeTrans;
                rj.transform.localPosition = new Vector3(-20 + i * 10, 10 - 1.2f * j, 0);
                rj.other  = prev;
                rj.anchor = new Vector3(-20 + i * 10, 11 - 1.2f * j, 0);
                prev      = rj.body;
            }

            yield return(0);

            NativeBox2D.API.ApplyLinearImpulse(prev.body, 200 * new Vector2(1, 0), Vector2.right);
        }
    }
示例#2
0
 void Awake()
 {
     body = GetComponent <B2DBody>();
 }
示例#3
0
 public void Awake()
 {
     body = GetComponent<B2DBody>();
 }