Exemple #1
0
    protected override void Initialise2(IntPtr world)
    {
        Vector3 anchorA = transform.position - BodyA.transform.position;
        Vector3 anchorB = transform.position - BodyB.transform.position;

        ThingPtr = LPAPIJoint.CreateRevoluteJoint(world, BodyA.GetComponent <LPBody>().GetPtr(), BodyB.GetComponent <LPBody>().GetPtr()
                                                  , anchorA.x, anchorA.y, anchorB.x, anchorB.y, CollideConnected);
        if (HasMotor)
        {
            LPAPIJoint.EnableRevoluteJointMotor(ThingPtr, HasMotor);
            LPAPIJoint.SetRevoluteJointMaxMotorTorque(ThingPtr, MaxMotorTorque);
            LPAPIJoint.SetRevoluteJointMotorSpeed(ThingPtr, MotorSpeed);
        }

        if (HasLimits)
        {
            LPAPIJoint.EnableRevoluteJointLimits(ThingPtr, HasLimits);
            LPAPIJoint.SetRevoluteJointLimits(ThingPtr, LowerLimit * Mathf.Deg2Rad, UpperLimit * Mathf.Deg2Rad);
        }
    }