public override void AttachHingesAndJoints()
    {
        //Create all the hinges and joints

        HingeParams HP = new HingeParams
        {
            Anchor = new Vector3(-0.08f, 0f, 0.7f),
            Axis   = new Vector3(0, 1, 0),
            Limits = new JointLimits {
                max = 60, min = -3
            }
        };

        partsMap["FLDoor"].Hinges.Add("FLDoor", HP);

        HP = new HingeParams
        {
            Anchor = new Vector3(-0.08f, 0f, 0.7f),
            Axis   = new Vector3(0, 1, 0),
            Limits = new JointLimits {
                max = 60, min = -0
            }
        };
        partsMap["FRDoor"].Hinges.Add("FRDoor", HP);

        base.AttachHingesAndJoints();
    }
    public override void AttachHingesAndJoints()
    {
        //Create all the hinges and joints
        HingeJoint BH;
        FixedJoint BF;
        GameObject LHood = car.transform.Find("LHood").gameObject;

        LHoodHinge = LHood.AddComponent <HingeJoint>();
        LHoodHinge.connectedBody = GetComponent <Rigidbody>();
        LHoodHinge.anchor        = new Vector3(0.32f, 0.1f, 0f);
        LHoodHinge.axis          = new Vector3(0, -0.08f, 1);
        LHoodHinge.useLimits     = true;
        JointLimits JL = new JointLimits();

        JL.max                 = -90;
        JL.min                 = 0;
        LHoodHinge.limits      = JL;
        LHoodHinge.breakForce  = 32000;
        LHoodHinge.breakTorque = 32000;
        LHoodHinge.GetComponent <Rigidbody>().mass = 20;

        GameObject RHood = car.transform.Find("RHood").gameObject;

        RHoodHinge = RHood.AddComponent <HingeJoint>();
        RHoodHinge.connectedBody = GetComponent <Rigidbody>();
        RHoodHinge.anchor        = new Vector3(-0.34f, 0.23f, 0f);
        RHoodHinge.axis          = new Vector3(0, -0.08f, -1);
        RHoodHinge.useLimits     = true;
        JointLimits JLRH = new JointLimits();

        JLRH.max               = -90;
        JLRH.min               = 0;
        RHoodHinge.limits      = JLRH;
        RHoodHinge.breakForce  = 1600;
        RHoodHinge.breakTorque = 1600;

        HingeParams HP = new HingeParams
        {
            Anchor = new Vector3(0, 0f, -0.48f),
            Axis   = new Vector3(0, 1, 0),
            Limits = new JointLimits {
                max = 10, min = -60
            }
        };

        partsMap["FLDoor"].Hinges.Add("FLDoor", HP);

        HP = new HingeParams
        {
            Anchor = new Vector3(0, 0f, 0.48f),
            Axis   = new Vector3(0.4f, 1, 0),
            Limits = new JointLimits {
                max = -40, min = 10
            }
        };
        partsMap["RFootplate"].Hinges.Add("RFootplate", HP);

        base.AttachHingesAndJoints();
    }
Esempio n. 3
0
    public override void AttachHingesAndJoints()
    {
        //Create all the hinges and joints
        GameObject LHood = car.transform.Find("Bonnet").gameObject;

        BonnetHinge = LHood.AddComponent <HingeJoint>();
        BonnetHinge.connectedBody = GetComponent <Rigidbody>();
        BonnetHinge.anchor        = new Vector3(0.32f, 0.05f, -0.47f);
        BonnetHinge.axis          = new Vector3(1, 0, 0);
        BonnetHinge.useLimits     = true;
        JointLimits JL = new JointLimits();

        JL.max                  = -50;
        JL.min                  = 0;
        BonnetHinge.limits      = JL;
        BonnetHinge.breakForce  = 32000;
        BonnetHinge.breakTorque = 32000;
        BonnetHinge.GetComponent <Rigidbody>().mass = 20;

        HingeParams HP = new HingeParams
        {
            Anchor = new Vector3(0, 0f, 0.59f),
            Axis   = new Vector3(0, 1, 0),
            Limits = new JointLimits {
                max = 60, min = -10
            }
        };

        partsMap["FLDoor"].Hinges.Add("FLDoor", HP);

        HP = new HingeParams
        {
            Anchor = new Vector3(0, 0f, 0.59f),
            Axis   = new Vector3(0, 1, 0),
            Limits = new JointLimits {
                max = 10, min = -60
            }
        };
        partsMap["FRDoor"].Hinges.Add("FRDoor", HP);

        HP = new HingeParams
        {
            Anchor = new Vector3(0.69f, 0f, 0f),
            Axis   = new Vector3(0, 1, -0.3f),
            Limits = new JointLimits {
                max = 0, min = -100
            }
        };
        partsMap["RBumper"].Hinges.Add("RBumper", HP);

        base.AttachHingesAndJoints();
    }
Esempio n. 4
0
    //This one used during play and replay
    public void AddHinge(string HingeName)
    {
        if (Transform.parent == null)
        {
            return;
        }
        HingeParams hp = Hinges[HingeName];
        HingeJoint  hj = Transform.gameObject.AddComponent <HingeJoint>();

        hj.connectedBody = Transform.parent.parent.GetComponent <Rigidbody>();
        hj.anchor        = hp.Anchor;
        hj.axis          = hp.Axis;
        hj.useLimits     = true;
        hj.limits        = hp.Limits;
        HasHinge         = true;
        if (Transform.gameObject.GetComponent <BoxCollider>() == null)
        {
            Transform.gameObject.AddComponent <BoxCollider>();//.sharedMaterial = StickyCarBodyPhysicsMaterial;
        }
    }
Esempio n. 5
0
    public override void AttachHingesAndJoints()
    {
        //Create all the hinges and joints
        HingeJoint BH;
        FixedJoint BF;
        GameObject Bonnet = car.transform.Find("Bonnet.FCrunch").gameObject;

        BonnetHinge = Bonnet.AddComponent <HingeJoint>();
        BonnetHinge.connectedBody = GetComponent <Rigidbody>();
        BonnetHinge.anchor        = new Vector3(0, -0.12f, 0.47f);
        BonnetHinge.axis          = new Vector3(1, 0, 0);
        BonnetHinge.useLimits     = true;
        JointLimits JL = new JointLimits();

        JL.max                  = 50;
        JL.min                  = 0;
        BonnetHinge.limits      = JL;
        BonnetHinge.breakForce  = 1500;
        BonnetHinge.breakTorque = 1500;
        GameObject BonnetFRCrunch = car.transform.Find("Bonnet.FRCrunch").gameObject;

        BH = BonnetFRCrunch.AddComponent <HingeJoint>();
        BH.connectedBody = GetComponent <Rigidbody>();
        BH.anchor        = new Vector3(0, 0.12f, 0.47f);
        BH.axis          = new Vector3(1, 0, 0);
        BH.useLimits     = true;
        BH.limits        = JL;
        BH.breakForce    = 1500;
        BH.breakTorque   = 1500;
        GameObject Trunk = car.transform.Find("Trunk").gameObject;

        BH = Trunk.AddComponent <HingeJoint>();
        BH.connectedBody = GetComponent <Rigidbody>();
        BH.anchor        = new Vector3(0, 0.26f, 0.59f); //Depends where you put the origin in Blender
        BH.axis          = new Vector3(1, 0, 0);
        BH.useLimits     = true;
        JointLimits TLim = new JointLimits();

        TLim.min  = 0;
        TLim.max  = 60;
        BH.limits = TLim;

        //BH.breakForce = 300f ;
        //BH.breakTorque = 300f;

        HingeParams HP = new HingeParams
        {
            Anchor = new Vector3(0, 0f, 0.59f),
            Axis   = new Vector3(0, 1, 0),
            Limits = new JointLimits {
                max = 60, min = -10
            }
        };

        partsMap["FLDoor"].Hinges.Add("FLDoor", HP);

        GameObject FRLight = car.transform.Find("FRLight").gameObject;

        BF = FRLight.AddComponent <FixedJoint>();
        BF.connectedBody = GetComponent <Rigidbody>();
        BF.breakForce    = 400;
        GameObject FLLight = car.transform.Find("FLLight").gameObject;

        BF = FLLight.AddComponent <FixedJoint>();
        BF.connectedBody = GetComponent <Rigidbody>();
        BF.breakForce    = 400;

        base.AttachHingesAndJoints();
    }