Beispiel #1
0
    //remember for cylinder, width (y - scale) is half of real

    public void Init(Vector3 position, float angle)
    {
        //следующее звено
        FixedJoint         fixedjoint   = GetComponent <FixedJoint>();
        GameObject         next         = fixedjoint.connectedBody.gameObject;
        wheel1manipulator2 nextbehavior = fixedjoint.connectedBody.GetComponent <wheel1manipulator2>();

        //размещаем следующее звено
        next.transform.localScale = new Vector3(nextbehavior.diameter, nextbehavior.width, nextbehavior.diameter);
        next.transform.position   = new Vector3(transform.position.x, transform.position.y, transform.position.z - (/*mul 2 for cylinder*/ 2 * width + /*mul 2 for cylinder*/ 2 * nextbehavior.width) / 2);

        //якорь шарнира
        fixedjoint.anchor = new Vector3(0.0f, 0.5f, 0.0f);

        //инициализируем следующие звенья
        nextbehavior.Init(position, angle);

        //поворачиваем вокруг вертикальной оси
        transform.RotateAround(position, Vector3.down, angle);
    }
Beispiel #2
0
    //remember for cylinder, width (y - scale) is half of real

    public void Init(Vector3 position, float angle)
    {
        //следующее звено
        FixedJoint      fixedjoint   = GetComponent <FixedJoint>();
        GameObject      next         = fixedjoint.connectedBody.gameObject;
        armmanipulator2 nextbehavior = fixedjoint.connectedBody.GetComponent <armmanipulator2>();

        //потребуются звенья
        wheel1manipulator2    wheel1    = wheel1object.GetComponent <wheel1manipulator2>();
        armhinge1manipulator2 armhinge1 = armhinge1object.GetComponent <armhinge1manipulator2>();

        //размещаем следующее звено
        next.transform.localScale = new Vector3(nextbehavior.width, nextbehavior.length, nextbehavior.width);
        next.transform.position   = new Vector3(transform.position.x - (nextbehavior.length / 2 - (wheel1.lever - armhinge1.diameter / 2)), transform.position.y, transform.position.z);

        //якорь шарнира
        fixedjoint.anchor = new Vector3(0.0f, 0.5f, 0.0f);

        //инициализируем следующие звенья
        nextbehavior.Init(position, angle);

        //поворачиваем вокруг вертикальной оси
        transform.RotateAround(position, Vector3.down, angle);
    }