コード例 #1
0
 static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.SoftJointLimit o;
         o = new UnityEngine.SoftJointLimit();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #2
0
ファイル: JointHelper.cs プロジェクト: piittis/scoreProject
    public static void attachChainHook(this ConfigurableJoint cj, GameObject attachedGo)
    {
        JointDrive jd = new JointDrive();
        jd.mode = JointDriveMode.Position;
        jd.positionDamper = 0.4f;
        cj.slerpDrive = jd;

        cj.xMotion = ConfigurableJointMotion.Locked;
        cj.yMotion = ConfigurableJointMotion.Locked;
        cj.zMotion = ConfigurableJointMotion.Locked;

        cj.angularXMotion = ConfigurableJointMotion.Limited;
        cj.angularYMotion = ConfigurableJointMotion.Limited;
        cj.angularZMotion = ConfigurableJointMotion.Limited;	//set limits again since this object rotation has been altered
        SoftJointLimit limit = new SoftJointLimit();
        limit.limit = -80f;
        cj.lowAngularXLimit = limit;

        limit.limit = 80f;
        cj.highAngularXLimit = limit;

        limit.limit = 3f;
        cj.angularYLimit = limit;

        limit.limit = 80f;
        cj.angularZLimit = limit;

        if (attachedGo.rigidbody != null)
            cj.connectedBody = attachedGo.rigidbody;
    }
コード例 #3
0
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.SoftJointLimit softJointLimit = (UnityEngine.SoftJointLimit)value;
     writer.WriteProperty("limit", softJointLimit.limit);
     writer.WriteProperty("bounciness", softJointLimit.bounciness);
     writer.WriteProperty("contactDistance", softJointLimit.contactDistance);
 }
コード例 #4
0
 public static SoftJointLimit NewJointLimit(float limit, SoftJointLimit referenceJointLimit, float min, float max)
 {
     SoftJointLimit newJointLimit = new SoftJointLimit();
     newJointLimit.limit = Mathf.Clamp(limit, min, max);
     newJointLimit.bounciness = referenceJointLimit.bounciness;
     return newJointLimit;
 }
コード例 #5
0
    void SetPhysicProperty(GameObject node, GameObject boundTo, bool isFixed)
    {
        var rb = node.AddComponent<Rigidbody> ();
        rb.mass = 1.0f;
        rb.drag = 0.1f;
        rb.angularDrag = 0.1f;

        if (isFixed) {
            rb.isKinematic = true;
        }

        if (boundTo != null) {
            var joint = node.AddComponent<ConfigurableJoint> ();
            joint.connectedBody = boundTo.rigidbody;

            var limit = new SoftJointLimit ();
            limit.limit = 0.1f;
            limit.spring = 40.0f;
            joint.linearLimit = limit;

            limit.limit = 10.0f;
            joint.angularYLimit = limit;
            joint.angularZLimit = limit;
            joint.highAngularXLimit = limit;
            joint.lowAngularXLimit = limit;

            joint.xMotion = ConfigurableJointMotion.Limited;
            joint.yMotion = ConfigurableJointMotion.Limited;
            joint.zMotion = ConfigurableJointMotion.Limited;
            joint.angularXMotion = ConfigurableJointMotion.Limited;
            joint.angularYMotion = ConfigurableJointMotion.Limited;
            joint.angularZMotion = ConfigurableJointMotion.Limited;
        }
    }
コード例 #6
0
    static public int set_bounciness(IntPtr l)
    {
        UnityEngine.SoftJointLimit o = (UnityEngine.SoftJointLimit)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.bounciness = v;
        setBack(l, o);
        return(0);
    }
コード例 #7
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.SoftJointLimit o;
         o = new UnityEngine.SoftJointLimit();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #8
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.SoftJointLimit o;
         o=new UnityEngine.SoftJointLimit();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
コード例 #9
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.SoftJointLimit o;
         o=new UnityEngine.SoftJointLimit();
         pushValue(l,true);
         pushValue(l,o);
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
コード例 #10
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.SoftJointLimit o;
         o = new UnityEngine.SoftJointLimit();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #11
0
 static void CharacterJoint_swing1Limit(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.CharacterJoint _this = (UnityEngine.CharacterJoint)vc.csObj;
         var result = _this.swing1Limit;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.SoftJointLimit arg0  = (UnityEngine.SoftJointLimit)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.CharacterJoint _this = (UnityEngine.CharacterJoint)vc.csObj;
         _this.swing1Limit = arg0;
     }
 }
コード例 #12
0
 static void ConfigurableJoint_angularZLimit(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.ConfigurableJoint _this = (UnityEngine.ConfigurableJoint)vc.csObj;
         var result = _this.angularZLimit;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.SoftJointLimit    arg0  = (UnityEngine.SoftJointLimit)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.ConfigurableJoint _this = (UnityEngine.ConfigurableJoint)vc.csObj;
         _this.angularZLimit = arg0;
     }
 }
コード例 #13
0
 static void SoftJointLimit_contactDistance(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.SoftJointLimit _this = (UnityEngine.SoftJointLimit)vc.csObj;
         var result = _this.contactDistance;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.SoftJointLimit _this = (UnityEngine.SoftJointLimit)vc.csObj;
         _this.contactDistance = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
コード例 #14
0
ファイル: RagdollController.cs プロジェクト: SeruK/Chatsent
        public void AddSkeletonBones()
        {
            foreach (Bone bone in bones) {
                Rigidbody rigidbody;
                CharacterJoint joint;

                GameObject go = FindInChildren (gameObject, bone.boneName);
                if (bone.rigidbody) {
                    rigidbody = go.AddComponent<Rigidbody> ();
                    rigidbody.interpolation = RigidbodyInterpolation.Extrapolate;
                    rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous;
                    rigidbody.mass = bone.mass;
                    rigidbody.isKinematic = false;
                }
                if (bone.joint) {
                    joint = go.AddComponent<CharacterJoint> ();
                    joint.enablePreprocessing = false;
                    joint.axis = bone.axis;

                    SoftJointLimit lowLimit = new SoftJointLimit ();
                    lowLimit.limit = bone.lowBendLimit;
                    joint.lowTwistLimit = lowLimit; // unity calls this twist it's really bend

                    SoftJointLimit highLimit = new SoftJointLimit ();
                    highLimit.limit = bone.highBendLimit;
                    joint.highTwistLimit = highLimit; // unity calls this twist it's really bend

                    SoftJointLimit twistLimit = new SoftJointLimit ();
                    twistLimit.limit = bone.twistLimit;
                    joint.swing1Limit = twistLimit; // the twist is + or - this value

                    joint.swing2Limit = new SoftJointLimit ();
                    joint.enablePreprocessing = true;
                }
            }

            // Need to traverse the list again after all the rigidbodies have been made.
            // This avoids relying on list order
            foreach (Bone bone in bones) {
                if (bone.joint) {
                    GameObject go = FindInChildren (gameObject, bone.boneName);
                    go.GetComponent<CharacterJoint> ().connectedBody = FindParentRigidbody (go);
                }
            }
        }
コード例 #15
0
    public void CopyValuesAndDestroyJoint(CharacterJoint characterJoint)
    {
        ConnectedBody = characterJoint.connectedBody;
        Anchor = characterJoint.anchor;
        Axis = characterJoint.axis;
        AutoConfigureConnectedAnchor = characterJoint.autoConfigureConnectedAnchor;
        ConnectedAnchor = characterJoint.connectedAnchor;
        SwingAxis = characterJoint.swingAxis;
        LowTwistLimit = characterJoint.lowTwistLimit;
        HighTwistLimit = characterJoint.highTwistLimit;
        Swing1Limit = characterJoint.swing1Limit;
        Swing2Limit = characterJoint.swing2Limit;
        BreakForce = characterJoint.breakForce;
        BreakTorque = characterJoint.breakTorque;
        EnableCollision = characterJoint.enableCollision;

        Destroy(characterJoint);
    }
コード例 #16
0
        /// <summary>
        /// Read the data using the reader.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public override object Read(ISaveGameReader reader)
        {
            UnityEngine.SoftJointLimit softJointLimit = new UnityEngine.SoftJointLimit();
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "limit":
                    softJointLimit.limit = reader.ReadProperty <System.Single> ();
                    break;

                case "bounciness":
                    softJointLimit.bounciness = reader.ReadProperty <System.Single> ();
                    break;

                case "contactDistance":
                    softJointLimit.contactDistance = reader.ReadProperty <System.Single> ();
                    break;
                }
            }
            return(softJointLimit);
        }
コード例 #17
0
    void AddJoint(GameObject node, GameObject boundTo)
    {
        var joint = node.AddComponent<ConfigurableJoint> ();
        joint.connectedBody = boundTo.rigidbody;

        var limit = new SoftJointLimit ();
        limit.limit = 0.1f;
        limit.spring = 40.0f;
        joint.linearLimit = limit;

        limit.limit = 10.0f;
        joint.angularYLimit = limit;
        joint.angularZLimit = limit;
        joint.highAngularXLimit = limit;
        joint.lowAngularXLimit = limit;

        joint.xMotion = ConfigurableJointMotion.Locked;
        joint.yMotion = ConfigurableJointMotion.Locked;
        joint.zMotion = ConfigurableJointMotion.Locked;
        joint.angularXMotion = ConfigurableJointMotion.Limited;
        joint.angularYMotion = ConfigurableJointMotion.Limited;
        joint.angularZMotion = ConfigurableJointMotion.Limited;
    }
コード例 #18
0
        /// <summary>
        /// Replaces a SpringJoint with a ConfigurableJoint.
        /// </summary>
        public static void SpringToConfigurable(SpringJoint src)
        {
            #if UNITY_EDITOR
            ConfigurableJoint conf = UnityEditor.Undo.AddComponent(src.gameObject, typeof(ConfigurableJoint)) as ConfigurableJoint;
            #else
            ConfigurableJoint conf = src.gameObject.AddComponent<ConfigurableJoint>();
            #endif

            ConvertJoint(ref conf, src as Joint);

            conf.xMotion = ConfigurableJointMotion.Limited;
            conf.yMotion = ConfigurableJointMotion.Limited;
            conf.zMotion = ConfigurableJointMotion.Limited;

            conf.angularXMotion = ConfigurableJointMotion.Free;
            conf.angularYMotion = ConfigurableJointMotion.Free;
            conf.angularZMotion = ConfigurableJointMotion.Free;

            SoftJointLimit linearLimit = new SoftJointLimit();
            linearLimit.bounciness = 0f;
            linearLimit.limit = src.maxDistance;
            conf.linearLimit = linearLimit;

            SoftJointLimitSpring linearLimitSpring = new SoftJointLimitSpring();
            linearLimitSpring.damper = src.damper;
            linearLimitSpring.spring = src.spring;
            conf.linearLimitSpring = linearLimitSpring;

            #if UNITY_EDITOR
            UnityEditor.Undo.DestroyObjectImmediate(src);
            #else
            GameObject.DestroyImmediate(src);
            #endif
        }
コード例 #19
0
 static public int get_spring(IntPtr l)
 {
     UnityEngine.SoftJointLimit o = (UnityEngine.SoftJointLimit)checkSelf(l);
     pushValue(l, o.spring);
     return(1);
 }
コード例 #20
0
 private extern void INTERNAL_set_highAngularXLimit(ref SoftJointLimit value);
コード例 #21
0
 private extern void INTERNAL_set_angularZLimit(ref SoftJointLimit value);
コード例 #22
0
 private void INTERNAL_set_swing2Limit(ref SoftJointLimit value);
コード例 #23
0
 private extern void INTERNAL_set_linearLimit(ref SoftJointLimit value);
コード例 #24
0
 private void INTERNAL_set_swing2Limit(ref SoftJointLimit value);
コード例 #25
0
 private void INTERNAL_get_highTwistLimit(out SoftJointLimit value);
コード例 #26
0
ファイル: CharacterJoint.cs プロジェクト: Hengle/JellyTerain
 private extern void INTERNAL_set_swing1Limit(ref SoftJointLimit value);
コード例 #27
0
        protected override bool DetectSetup()
        {
            finalDirection = (direction == ButtonDirection.autodetect) ? DetectDirection() : direction;
            if (finalDirection == ButtonDirection.autodetect)
            {
                activationDir = Vector3.zero;
                return false;
            }
            if (direction != ButtonDirection.autodetect)
            {
                activationDir = CalculateActivationDir();
            }

            if (cf)
            {
                cf.force = GetForceVector();
            }

            if (Application.isPlaying)
            {
                cj = GetComponent<ConfigurableJoint>();

                bool recreate = false;
                Rigidbody oldBody = null;
                Vector3 oldAnchor = Vector3.zero;
                Vector3 oldAxis = Vector3.zero;

                if (cj)
                {
                    // save old values, needs to be recreated
                    oldBody = cj.connectedBody;
                    oldAnchor = cj.anchor;
                    oldAxis = cj.axis;
                    DestroyImmediate(cj);
                    recreate = true;
                }

                // since limit applies to both directions object needs to be moved halfway to activation before adding joint
                transform.position = transform.position + activationDir.normalized * activationDistance * 0.5f;
                cj = gameObject.AddComponent<ConfigurableJoint>();

                if (recreate)
                {
                    cj.connectedBody = oldBody;
                    cj.anchor = oldAnchor;
                    cj.axis = oldAxis;
                }
                if (connectedTo)
                {
                    cj.connectedBody = connectedTo.GetComponent<Rigidbody>();
                }

                SoftJointLimit sjl = new SoftJointLimit();
                sjl.limit = activationDistance * 0.501f; // set limit to half (since it applies to both directions) and a tiny bit larger since otherwise activation distance might be missed
                cj.linearLimit = sjl;

                cj.angularXMotion = ConfigurableJointMotion.Locked;
                cj.angularYMotion = ConfigurableJointMotion.Locked;
                cj.angularZMotion = ConfigurableJointMotion.Locked;
                cj.xMotion = ConfigurableJointMotion.Locked;
                cj.yMotion = ConfigurableJointMotion.Locked;
                cj.zMotion = ConfigurableJointMotion.Locked;

                switch (finalDirection)
                {
                    case ButtonDirection.x:
                    case ButtonDirection.negX:
                        if (Mathf.RoundToInt(Mathf.Abs(transform.right.x)) == 1)
                        {
                            cj.xMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.up.x)) == 1)
                        {
                            cj.yMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.forward.x)) == 1)
                        {
                            cj.zMotion = ConfigurableJointMotion.Limited;
                        }
                        break;
                    case ButtonDirection.y:
                    case ButtonDirection.negY:
                        if (Mathf.RoundToInt(Mathf.Abs(transform.right.y)) == 1)
                        {
                            cj.xMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.up.y)) == 1)
                        {
                            cj.yMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.forward.y)) == 1)
                        {
                            cj.zMotion = ConfigurableJointMotion.Limited;
                        }
                        break;
                    case ButtonDirection.z:
                    case ButtonDirection.negZ:
                        if (Mathf.RoundToInt(Mathf.Abs(transform.right.z)) == 1)
                        {
                            cj.xMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.up.z)) == 1)
                        {
                            cj.yMotion = ConfigurableJointMotion.Limited;
                        }
                        else if (Mathf.RoundToInt(Mathf.Abs(transform.forward.z)) == 1)
                        {
                            cj.zMotion = ConfigurableJointMotion.Limited;
                        }
                        break;
                }
            }

            return true;
        }
コード例 #28
0
ファイル: CharacterJoint.cs プロジェクト: Hengle/JellyTerain
 private extern void INTERNAL_get_swing1Limit(out SoftJointLimit value);
コード例 #29
0
ファイル: CharacterJoint.cs プロジェクト: Hengle/JellyTerain
 private extern void INTERNAL_set_lowTwistLimit(ref SoftJointLimit value);
コード例 #30
0
ファイル: CharacterJoint.cs プロジェクト: Hengle/JellyTerain
 private extern void INTERNAL_get_lowTwistLimit(out SoftJointLimit value);
コード例 #31
0
        public void LoadBoomHead()
        {
            if (savedSectionsLocalPos.Count > 0) {
              //Reset section(s) to org pos
              foreach (KeyValuePair<int, SectionInfo> section in sections) {
            section.Value.transform.position = part.transform.TransformPoint(section.Value.orgLocalPos);
              }
            }

            KAS_Shared.DebugLog("LoadBoomHead(TelescopicArm) Create physical object...");
            boomHeadPhysicModule = this.part.gameObject.GetComponent<KASModulePhysicChild>();
            if (!boomHeadPhysicModule) {
              KAS_Shared.DebugLog(
              "LoadBoomHead(TelescopicArm) - KASModulePhysicChild do not exist, adding it...");
              boomHeadPhysicModule = this.part.gameObject.AddComponent<KASModulePhysicChild>();
            }
            boomHeadPhysicModule.StartPhysics(sections[0].transform.gameObject, boomHeadMass);

            orgBoomHeadMass = this.part.mass;
            float newMass = this.part.mass - boomHeadMass;
            if (newMass > 0) {
              this.part.mass = newMass;
            } else {
              KAS_Shared.DebugWarning(
              "LoadBoomHead(TelescopicArm) - Mass of the boom head is greater than the part !");
            }

            KAS_Shared.DebugLog("LoadRotor - Disable collision...");
            disableSectionCollision();

            KAS_Shared.DebugLog("LoadBoomHead(TelescopicArm) - Create configurable joint...");
            slideJoint = this.part.gameObject.AddComponent<ConfigurableJoint>();
            slideJoint.connectedBody = sections[0].transform.GetComponent<Rigidbody>();
            slideJoint.axis = Vector3.zero;
            slideJoint.secondaryAxis = Vector3.zero;
            slideJoint.breakForce = breakForce;
            slideJoint.breakTorque = breakForce;
            slideJoint.angularXMotion = ConfigurableJointMotion.Locked;
            slideJoint.angularYMotion = ConfigurableJointMotion.Locked;
            slideJoint.angularZMotion = ConfigurableJointMotion.Locked;
            slideJoint.xMotion = ConfigurableJointMotion.Locked;
            slideJoint.yMotion = ConfigurableJointMotion.Locked;
            slideJoint.zMotion = ConfigurableJointMotion.Locked;

            if (direction.x != 0) {
              slideJoint.xMotion = ConfigurableJointMotion.Limited;
              driveWay = direction.x;
              KAS_Shared.DebugLog(
              "LoadBoomHead(TelescopicArm) - Direction set to x axis with driveWay set to : "
              + driveWay);
            } else if (direction.y != 0) {
              slideJoint.yMotion = ConfigurableJointMotion.Limited;
              driveWay = direction.y;
              KAS_Shared.DebugLog(
              "LoadBoomHead(TelescopicArm) - Direction set to y axis with driveWay set to : "
              + driveWay);
            } else if (direction.z != 0) {
              slideJoint.zMotion = ConfigurableJointMotion.Limited;
              driveWay = direction.z;
              KAS_Shared.DebugLog(
              "LoadBoomHead(TelescopicArm) - Direction set to z axis with driveWay set to : "
              + driveWay);
            }

            JointDrive drv = new JointDrive();
            drv.mode = JointDriveMode.PositionAndVelocity;
            drv.positionSpring = driveSpring;
            drv.positionDamper = driveDamper;
            drv.maximumForce = driveForce;
            slideJoint.xDrive = slideJoint.yDrive = slideJoint.zDrive = drv;

            var jointLimit = new SoftJointLimit();
            jointLimit.limit = sectionTotalLenght;
            jointLimit.bounciness = 1;
            slideJoint.linearLimit = jointLimit;
            slideJoint.linearLimitSpring = new SoftJointLimitSpring() {
              damper = 200,
              spring = 1000
            };

            if (savedSectionsLocalPos.Count > 0) {
              KAS_Shared.DebugLog("LoadBoomHead(TelescopicArm) - Re-set section position from save");
              float sumLenght = 0;
              foreach (KeyValuePair<int, SectionInfo> section in sections) {
            KAS_Shared.DebugLog("LoadBoomHead(TelescopicArm) - Move section " + section.Key
                            + " to local position : " + section.Value.savedLocalPos);
            section.Value.transform.position =
            part.transform.TransformPoint(section.Value.savedLocalPos);
            sumLenght += section.Value.lenght;
            if (headPos > sumLenght) {
              KAS_Shared.DebugLog("LoadBoomHead(TelescopicArm) - Parent section "
                              + sections[section.Key + 1].transform.name + " to : "
                              + section.Value.transform.name);
              sections[section.Key + 1].transform.parent = section.Value.transform;
            }
              }
            }

            // Get boom head attach nodes
            attachNodes.Clear();
            ConfigNode node = KAS_Shared.GetBaseConfigNode(this);
            List<string> attachNodesSt = new List<string>(node.GetValues("attachNode"));
            foreach (String anString in attachNodesSt) {
              AttachNode an = this.part.findAttachNode(anString);
              if (an != null) {
            KAS_Shared.DebugLog("LoadBoomHead(TelescopicArm) - Boom head attach node added : " + an.id);
            attachNodes.Add(an);
            if (an.attachedPart) {
              KAS_Shared.DebugLog("LoadBoomHead(TelescopicArm) - Setting boom head joint on : "
                              + an.attachedPart.partInfo.title);
              KAS_Shared.RemoveFixedJointBetween(this.part, an.attachedPart);
              KAS_Shared.RemoveHingeJointBetween(this.part, an.attachedPart);
              FixedJoint fjnt = an.attachedPart.gameObject.AddComponent<FixedJoint>();
              fjnt.connectedBody = sections[0].transform.GetComponent<Rigidbody>();
              fixedJnts.Add(fjnt);
            }
              }
            }
            SetTargetPos(targetPos);
            boomHeadLoaded = true;
        }
コード例 #32
0
 private extern void set_swing2Limit_Injected(ref SoftJointLimit value);
コード例 #33
0
    void NewJoint( int i )
    {
        GameObject tJC;
        ConfigurableJoint tCJ;
        SoftJointLimit sjl;
        JointDrive jd;
        //CapsuleCollider cc;

        tJC = new GameObject("Connection_"+i.ToString());
        tJC.transform.position = ropeEnd.transform.position + (jointHeading * linkLength * i);
        tJC.transform.LookAt(transform.position);

        Debug.Log( i );
        if( jointParent == null ) {
            tJC.transform.parent = GameObject.Find( "Rope" ).transform;
        }
        else {
            tJC.transform.parent = jointParent.transform;
        }
        tJC.AddComponent<Rigidbody>();
        //tJC.rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
        tJC.rigidbody.angularDrag = 0;

        switch(constraintPlane)
        {
            case ConstraintPlane.X_Y:
                tJC.rigidbody.constraints = RigidbodyConstraints.FreezePositionZ;
                break;
            case ConstraintPlane.Y_Z:
                tJC.rigidbody.constraints = RigidbodyConstraints.FreezePositionX;
                break;
            case ConstraintPlane.Z_X:
                tJC.rigidbody.constraints = RigidbodyConstraints.FreezePositionY;
                break;
            default:
                break;
        }

        /* Uncomment this to add capsule colliders to the links.
        if(i<linkCount)
        {
            cc = tJC.AddComponent<CapsuleCollider>();
            cc.center = new Vector3(0,0,jointGap/2);
            cc.height = jointGap * 1.33f;
            cc.direction = 2;
            cc.radius = ropeRadius;
        }*/

        tCJ = tJC.AddComponent<ConfigurableJoint>();
        tCJ.configuredInWorldSpace = true;
        try{tCJ.connectedBody = jointConnections[i-1].rigidbody; }catch{ tCJ.connectedBody = ropeEnd.rigidbody; }

        //tCJ.swingAxis = new Vector3(1,1,1);
        tCJ.xMotion = ConfigurableJointMotion.Locked;
        tCJ.yMotion = ConfigurableJointMotion.Locked;
        tCJ.zMotion = ConfigurableJointMotion.Locked;

        tCJ.angularXMotion = ConfigurableJointMotion.Locked;
        tCJ.angularYMotion = ConfigurableJointMotion.Locked;
        tCJ.angularZMotion = ConfigurableJointMotion.Locked;
        /*
        tCJ.angularXMotion = ConfigurableJointMotion.Limited;
        tCJ.highAngularXLimit = new SoftJointLimit(){ limit = 360.0f };
        tCJ.lowAngularXLimit = new SoftJointLimit(){ limit = 0.0f };
        tCJ.angularYMotion = ConfigurableJointMotion.Limited;
        tCJ.angularYLimit = new SoftJointLimit(){ limit = 360.0f };
        tCJ.angularZMotion = ConfigurableJointMotion.Limited;
        tCJ.angularZLimit = new SoftJointLimit(){ limit = 360 }; //MinMaxTwist };
        */

        jd = new JointDrive() { mode = JointDriveMode.Position };
        tCJ.xDrive = jd;
        tCJ.yDrive = jd;
        tCJ.zDrive = jd;

        if(i == linkCount)
        {
            // first, update the old end
            /*
            if( i > 1 ) {
                ConfigurableJoint oldcj = (ConfigurableJoint) jointConnections[i-1].GetComponent( "ConfigurableJoint" );
                oldcj.angularXMotion = ConfigurableJointMotion.Locked;
                oldcj.angularYMotion = ConfigurableJointMotion.Locked;
                oldcj.angularZMotion = ConfigurableJointMotion.Locked;

                oldcj.connectedBody = jointConnections[i-2].rigidbody;
            }
            */

            tCJ = tJC.AddComponent<ConfigurableJoint>();

            tCJ.connectedBody = rigidbody;
            tCJ.xMotion = ConfigurableJointMotion.Locked;
            tCJ.yMotion = ConfigurableJointMotion.Locked;
            tCJ.zMotion = ConfigurableJointMotion.Locked;

            tCJ.angularZMotion = ConfigurableJointMotion.Limited;
            sjl = new SoftJointLimit(){ limit = MinMaxTwist };
            tCJ.angularZLimit = sjl;

            jd = new JointDrive() { mode = JointDriveMode.Position };
            tCJ.xDrive = jd;
            tCJ.yDrive = jd;
            tCJ.zDrive = jd;

            tCJ.projectionMode = JointProjectionMode.PositionOnly;
            tCJ.projectionDistance = 0.1f;
        }

        /*
        tCJ.projectionMode = JointProjectionMode.PositionAndRotation;
        tCJ.projectionDistance = 0.1f;
        tCJ.projectionAngle = .1f;
        tCJ.targetRotation = Quaternion.LookRotation( Vector3.up);
        tCJ.angularXDrive = new JointDrive() { mode = JointDriveMode.Position };
        tCJ.angularYZDrive = new JointDrive() { mode = JointDriveMode.Position };
        */
        jointConnections.Add( tJC );
    }
コード例 #34
0
 static public int get_damper(IntPtr l)
 {
     UnityEngine.SoftJointLimit o = (UnityEngine.SoftJointLimit)checkSelf(l);
     pushValue(l, o.damper);
     return(1);
 }
コード例 #35
0
 private void INTERNAL_set_highTwistLimit(ref SoftJointLimit value);
コード例 #36
0
 static public int get_bounciness(IntPtr l)
 {
     UnityEngine.SoftJointLimit o = (UnityEngine.SoftJointLimit)checkSelf(l);
     pushValue(l, o.bounciness);
     return(1);
 }
コード例 #37
0
 private extern void get_swing2Limit_Injected(out SoftJointLimit ret);
コード例 #38
0
 private extern void get_highTwistLimit_Injected(out SoftJointLimit ret);
コード例 #39
0
 private extern void INTERNAL_get_linearLimit(out SoftJointLimit value);
コード例 #40
0
 // Returns a copy of the specified SoftJointLimit
 private static SoftJointLimit CopyLimit(SoftJointLimit src)
 {
     SoftJointLimit limit = new SoftJointLimit();
     limit.limit = src.limit;
     limit.bounciness = src.bounciness;
     return limit;
 }
コード例 #41
0
 private extern void INTERNAL_get_highAngularXLimit(out SoftJointLimit value);
コード例 #42
0
		private extern void INTERNAL_get_linearLimit(out SoftJointLimit value);
コード例 #43
0
 private extern void INTERNAL_get_angularZLimit(out SoftJointLimit value);
コード例 #44
0
		private extern void INTERNAL_set_linearLimit(ref SoftJointLimit value);
コード例 #45
0
    void SetupJoint(ConfigurableJoint joint)
    {
        SoftJointLimit jointLimit = new SoftJointLimit();
		jointLimit.spring     = 0.0f;
		jointLimit.damper     = 0.0f;
		jointLimit.bounciness = 0.0f;
		
		JointDrive jointDrive     = new JointDrive();
		jointDrive.mode           = JointDriveMode.Position;
		jointDrive.positionSpring = LinkJointSpringValue;
		jointDrive.positionDamper = LinkJointDamperValue;
		jointDrive.maximumForce   = LinkJointMaxForceValue;

        joint.axis              = Vector3.right;
        joint.secondaryAxis     = Vector3.up;
		joint.breakForce        = LinkJointBreakForce;
		joint.breakTorque       = LinkJointBreakTorque;

		joint.xMotion           = ConfigurableJointMotion.Locked;
		joint.yMotion           = ConfigurableJointMotion.Locked;
		joint.zMotion           = ConfigurableJointMotion.Locked;
		joint.angularXMotion    = Mathf.Approximately(LinkJointAngularXLimit, 0.0f) == false ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
		joint.angularYMotion    = Mathf.Approximately(LinkJointAngularYLimit, 0.0f) == false ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;
		joint.angularZMotion    = Mathf.Approximately(LinkJointAngularZLimit, 0.0f) == false ? ConfigurableJointMotion.Limited : ConfigurableJointMotion.Locked;

		jointLimit.limit        = -LinkJointAngularXLimit;
		joint.lowAngularXLimit  = jointLimit;

		jointLimit.limit        = LinkJointAngularXLimit;
		joint.highAngularXLimit = jointLimit;

        jointLimit.limit        = LinkJointAngularYLimit;
		joint.angularYLimit     = jointLimit;

        jointLimit.limit        = LinkJointAngularZLimit;
		joint.angularZLimit     = jointLimit;

        joint.angularXDrive     = jointDrive;
		joint.angularYZDrive    = jointDrive;
/*
        joint.projectionMode     = JointProjectionMode.PositionAndRotation;
        joint.projectionDistance = 0.1f;
        joint.projectionAngle    = 0.1f;*/
    }
コード例 #46
0
 // Conversion from JointLimit and JointSpring to low SoftJointLimit
 private static SoftJointLimit ConvertToLowSoftJointLimit(JointLimits src, JointSpring spring, bool useSpring)
 {
     SoftJointLimit limit = new SoftJointLimit();
     limit.limit = -src.min;
     limit.bounciness = src.bounciness;
     return limit;
 }
コード例 #47
0
	protected virtual void OnPress(bool isPressed)
	{
    if (!isPressed)
	  {
      truckCar.position = raceStart.CharPos.position;
      truckCar.rotation = raceStart.CharPos.rotation;
      
      baggageLabel.BaggageController = truckCar.GetComponentInChildren<BlowController>();

      GameObject t = Instantiate(trailer, Vector3.zero, Quaternion.identity) as GameObject;
      Trailer tr = t.GetComponentInChildren<Trailer>();  //Находим прицепа, 
      if (tr != null)
      {
        tr.transform.position = truckCar.position;
        tr.transform.rotation = truckCar.rotation;
        truckCar.gameObject.AddComponent<CharacterJoint>();
        CharacterJoint characterJoint = truckCar.GetComponent<CharacterJoint>();
        characterJoint.connectedBody = tr.GetComponentInChildren<Rigidbody>();
        characterJoint.anchor = connectPosition;
        SoftJointLimit softJointLimit = new SoftJointLimit();
        //softJointLimit.limit = 0;
        //characterJoint.lowTwistLimit = softJointLimit;
        softJointLimit.limit = 25;
        characterJoint.highTwistLimit = softJointLimit;//вертикальный сустав
        softJointLimit.limit = 105;
        characterJoint.swing1Limit = softJointLimit;//горизонтальный сустав
        //softJointLimit.limit = 5;
        //truckCar.GetComponent<CharacterJoint>().swing2Limit = softJointLimit;//left/right
        truckCar.GetComponent<BlowController>().Frailty = tr.Frailty;//Передаем хрупкость на тягач
        truckCar.GetComponent<BlowController>().Condition = 100;
        truckCar.GetComponent<AxisCarController>().Trailer = tr.GetComponentInChildren<Rigidbody>();
        truckCar.GetComponent<AxisCarController>().SignalTrailerLeft = tr.SignalLeft;
        truckCar.GetComponent<AxisCarController>().SignalTrailerRight = tr.SignalRight;
        truckCar.GetComponentInChildren<BlowController>().TrailerTransform = tr.GetComponentInChildren<Rigidbody>().transform;
        truckCar.GetComponentInChildren<BlowController>().Box = tr.Box;
      }
      Array.Resize(ref enemies, raceStart.enemiesPos.Length);
	    int i = 0;
      foreach (var e in raceStart.enemiesPos)//Создаем соперников
      {
        GameObject enemyTractor = Instantiate(raceStart.enemiesPos[i].EnemyPref, e.EnemyPos.position, e.EnemyPos.rotation) as GameObject;
        if (enemyTractor != null)
        {
          raceStart.mapScroll.Enemies[i] = enemyTractor.transform;//b
          enemyTractor.GetComponentInChildren<AxisCarController>().SetWay(way);
          enemies[i] = enemyTractor;
          GameObject ts = Instantiate(trailer, Vector3.zero, Quaternion.identity) as GameObject;
          //Destroy(ts.GetComponentInChildren<Skidmarks>().gameObject);//Удалить следы у соперников
          Trailer trs = ts.GetComponentInChildren<Trailer>();  //Находим прицепа soprnika, 
          if (trs != null)
          {
            trs.transform.position = enemyTractor.transform.position;
            trs.transform.rotation = enemyTractor.transform.rotation;
            enemyTractor.GetComponent<CharacterJoint>().connectedBody = trs.GetComponentInChildren<Rigidbody>();
            enemyTractor.GetComponent<AxisCarController>().Trailer = trs.GetComponentInChildren<Rigidbody>();
            enemyTractor.GetComponent<AxisCarController>().SignalTrailerLeft = trs.GetComponent<Trailer>().SignalLeft;
            enemyTractor.GetComponent<AxisCarController>().SignalTrailerRight = trs.GetComponent<Trailer>().SignalRight;
            enemyTractor.GetComponentInChildren<RenderContainer>().trailer = trs.GetComponentInChildren<Rigidbody>();
            enemyTractor.GetComponentInChildren<BlowController>().TrailerTransform = trs.GetComponentInChildren<Rigidbody>().transform;
            enemyTractor.GetComponentInChildren<BlowController>().Box = trs.Box;
            enemyTractor.GetComponent<BlowController>().Frailty = trs.Frailty;//Передаем хрупкость на тягач
            enemyTractor.GetComponent<BlowController>().Condition = 100;
          }
          i += 1;
        }
        else Debug.LogWarning("opp == null");
      }
      raceFinish.Activ = true;
      raceStart.ExitStation();
      raceStart.ClockOn();
	    raceFinish.Price = price;
	    raceFinish.buttonAddTrailer = this;
	    buttonThrottle.NitroFuel = 100;
      //
	    CarZona[] carZones = FindObjectsOfType<CarZona>();
	    foreach (var carZone in carZones)
	    {
	      carZone.Enemies = enemies;
	    }
      //Создание бонусов
      baggageLabel.bonusPosCtrl.CreateBonuses(cargoId);
      raceStart.MapCamera.SetActive(true);
	  }
	}
コード例 #48
0
		private extern void INTERNAL_set_highAngularXLimit(ref SoftJointLimit value);
コード例 #49
0
		private extern void INTERNAL_get_angularZLimit(out SoftJointLimit value);
コード例 #50
0
		private extern void INTERNAL_set_angularZLimit(ref SoftJointLimit value);
コード例 #51
0
	void PlaceJointConnections()
	{	
		if(Application.isPlaying)
			jointParent = new GameObject("Rope");
		else
			jointParent = new GameObject("TempRope");
		
		jointParent.transform.position = ropeEnd.transform.position;
		jointParent.transform.LookAt(transform.position);
		
		GameObject tJC;
		ConfigurableJoint tCJ;
		SoftJointLimit sjl;
		JointDrive jd;
		CapsuleCollider cc;
		SphereCollider sc;
		
		for(int i = 0; i <= linkCount; i++)
		{
			tJC = new GameObject("Connection_"+i.ToString());
			tJC.transform.position = ropeEnd.transform.position + (jointHeading * jointGap * i);
			tJC.transform.LookAt(transform.position + jointHeading);
			
			tJC.transform.parent = jointParent.transform;
			tJC.AddComponent<Rigidbody>();
			tJC.rigidbody.drag = jointDrag;
			tJC.rigidbody.useGravity = jointsHaveGravity;
			
			switch(constraintPlane)
			{
				case ConstraintPlane.X_Y:
					tJC.rigidbody.constraints = RigidbodyConstraints.FreezePositionZ;
					break;
				case ConstraintPlane.Y_Z:
					tJC.rigidbody.constraints = RigidbodyConstraints.FreezePositionX;
					break;
				case ConstraintPlane.Z_X:
					tJC.rigidbody.constraints = RigidbodyConstraints.FreezePositionY;
					break;
				default:
					break;
			}
			
			if(includeSphereColliders)
			{
				sc = tJC.AddComponent<SphereCollider>();
				sc.radius = ropeRadius;
				sc.material = ropePhysicMaterial;
			}
			
			if(includeCapsuleColliders && i<linkCount)
			{
				cc = tJC.AddComponent<CapsuleCollider>();
				cc.center = new Vector3(0,0,jointGap/2);
				cc.height = jointGap * 1.33f;
				cc.direction = 2;
				cc.radius = ropeRadius;
				cc.material = ropePhysicMaterial;
			}
			
			tCJ = tJC.AddComponent<ConfigurableJoint>();
			try{tCJ.connectedBody = jointConnections[i-1].rigidbody; }catch{ tCJ.connectedBody = ropeEnd.rigidbody; }
			
			//tCJ.swingAxis = new Vector3(1,1,1);
			tCJ.xMotion = ConfigurableJointMotion.Locked;
			tCJ.yMotion = ConfigurableJointMotion.Locked;
			tCJ.zMotion = ConfigurableJointMotion.Locked;
			
			tCJ.angularZMotion = ConfigurableJointMotion.Limited;
			sjl = new SoftJointLimit(){ limit = MinMaxTwist };
			tCJ.angularZLimit = sjl;
		
			
			jd = new JointDrive() { mode = JointDriveMode.Position };
			tCJ.xDrive = jd;
			tCJ.yDrive = jd;
			tCJ.zDrive = jd; 
			
			tCJ.projectionMode = JointProjectionMode.PositionOnly;
			tCJ.projectionDistance = 0.1f;
			
			
			if(i == linkCount)
			{
				tCJ = tJC.AddComponent<ConfigurableJoint>();
					
				tCJ.connectedBody = rigidbody;
				tCJ.xMotion = ConfigurableJointMotion.Locked;
				tCJ.yMotion = ConfigurableJointMotion.Locked;
				tCJ.zMotion = ConfigurableJointMotion.Locked;
				
				tCJ.angularZMotion = ConfigurableJointMotion.Limited;
				sjl = new SoftJointLimit(){ limit = MinMaxTwist };
				tCJ.angularZLimit = sjl;
				
				jd = new JointDrive() { mode = JointDriveMode.Position };
				tCJ.xDrive = jd;
				tCJ.yDrive = jd;
				tCJ.zDrive = jd; 
				
				tCJ.projectionMode = JointProjectionMode.PositionOnly;
				tCJ.projectionDistance = 0.1f;	
			}
			
			jointConnections.Add(tJC);
		}
	}
コード例 #52
0
ファイル: PMXConverter.cs プロジェクト: hsnk/mmd-for-unity
        /// <summary>
        /// ジョイントに移動・回転制限のパラメータを設定する
        /// </summary>
        /// <param name='joint'>PMX用ジョイントデータ</param>
        /// <param name='conf'>Unity用ジョイント</param>
        void SetMotionAngularLock(PMXFormat.Joint joint, ConfigurableJoint conf)
        {
            SoftJointLimit jlim;

            // Motionの固定
            if (joint.constrain_pos_lower.x == 0.0f && joint.constrain_pos_upper.x == 0.0f) {
                conf.xMotion = ConfigurableJointMotion.Locked;
            } else {
                conf.xMotion = ConfigurableJointMotion.Limited;
            }

            if (joint.constrain_pos_lower.y == 0.0f && joint.constrain_pos_upper.y == 0.0f) {
                conf.yMotion = ConfigurableJointMotion.Locked;
            } else {
                conf.yMotion = ConfigurableJointMotion.Limited;
            }

            if (joint.constrain_pos_lower.z == 0.0f && joint.constrain_pos_upper.z == 0.0f) {
                conf.zMotion = ConfigurableJointMotion.Locked;
            } else {
                conf.zMotion = ConfigurableJointMotion.Limited;
            }

            // 角度の固定
            if (joint.constrain_rot_lower.x == 0.0f && joint.constrain_rot_upper.x == 0.0f) {
                conf.angularXMotion = ConfigurableJointMotion.Locked;
            } else {
                conf.angularXMotion = ConfigurableJointMotion.Limited;
                float hlim = Mathf.Max(-joint.constrain_rot_lower.x, -joint.constrain_rot_upper.x); //回転方向が逆なので負数
                float llim = Mathf.Min(-joint.constrain_rot_lower.x, -joint.constrain_rot_upper.x);
                SoftJointLimit jhlim = new SoftJointLimit();
                jhlim.limit = Mathf.Clamp(hlim * Mathf.Rad2Deg, -180.0f, 180.0f);
                conf.highAngularXLimit = jhlim;

                SoftJointLimit jllim = new SoftJointLimit();
                jllim.limit = Mathf.Clamp(llim * Mathf.Rad2Deg, -180.0f, 180.0f);
                conf.lowAngularXLimit = jllim;
            }

            if (joint.constrain_rot_lower.y == 0.0f && joint.constrain_rot_upper.y == 0.0f) {
                conf.angularYMotion = ConfigurableJointMotion.Locked;
            } else {
                // 値がマイナスだとエラーが出るので注意
                conf.angularYMotion = ConfigurableJointMotion.Limited;
                float lim = Mathf.Min(Mathf.Abs(joint.constrain_rot_lower.y), Mathf.Abs(joint.constrain_rot_upper.y));//絶対値の小さい方
                jlim = new SoftJointLimit();
                jlim.limit = lim * Mathf.Clamp(Mathf.Rad2Deg, 0.0f, 180.0f);
                conf.angularYLimit = jlim;
            }

            if (joint.constrain_rot_lower.z == 0f && joint.constrain_rot_upper.z == 0f) {
                conf.angularZMotion = ConfigurableJointMotion.Locked;
            } else {
                conf.angularZMotion = ConfigurableJointMotion.Limited;
                float lim = Mathf.Min(Mathf.Abs(-joint.constrain_rot_lower.z), Mathf.Abs(-joint.constrain_rot_upper.z));//絶対値の小さい方//回転方向が逆なので負数
                jlim = new SoftJointLimit();
                jlim.limit = Mathf.Clamp(lim * Mathf.Rad2Deg, 0.0f, 180.0f);
                conf.angularZLimit = jlim;
            }
        }
コード例 #53
0
ファイル: Toggle.cs プロジェクト: Majiir/MuMechLib
    protected bool setupJoints()
    {
        if (!gotOrig)
        {
            if ((rotate_model != "") && (transform.FindChild("model").FindChild(rotate_model) != null))
            {
                origRotation = transform.FindChild("model").FindChild(rotate_model).localRotation;
            }
            if (translateJoint)
            {
                origTranslation = transform.localPosition;
            }
            else if ((translate_model != "") && (transform.FindChild("model").FindChild(translate_model) != null))
            {
                origTranslation = transform.FindChild("model").FindChild(translate_model).localPosition;
            }
            if (rotateJoint || translateJoint)
            {
                if (attachJoint != null)
                {
                    GameObject.Destroy(attachJoint);
                    ConfigurableJoint newJoint = gameObject.AddComponent<ConfigurableJoint>();
                    newJoint.breakForce = breakingForce;
                    newJoint.breakTorque = breakingTorque;
                    newJoint.axis = rotateJoint ? rotateAxis : translateAxis;
                    newJoint.secondaryAxis = (newJoint.axis == Vector3.up) ? Vector3.forward : Vector3.up;
                    SoftJointLimit spring = new SoftJointLimit();
                    spring.limit = 0;
                    spring.damper = jointDamping;
                    spring.spring = jointSpring;
                    if (translateJoint)
                    {
                        newJoint.xMotion = ConfigurableJointMotion.Free;
                        newJoint.yMotion = ConfigurableJointMotion.Free;
                        newJoint.zMotion = ConfigurableJointMotion.Free;
                        //newJoint.linearLimit = spring;
                        JointDrive drv = new JointDrive();
                        drv.mode = JointDriveMode.PositionAndVelocity;
                        drv.positionSpring = 1e20F;
                        drv.positionDamper = 0;
                        drv.maximumForce = 1e20F;
                        newJoint.xDrive = newJoint.yDrive = newJoint.zDrive = drv;
                    }
                    else
                    {
                        newJoint.xMotion = ConfigurableJointMotion.Locked;
                        newJoint.yMotion = ConfigurableJointMotion.Locked;
                        newJoint.zMotion = ConfigurableJointMotion.Locked;
                    }
                    if (rotateJoint)
                    {
                        newJoint.angularXMotion = ConfigurableJointMotion.Limited;
                        newJoint.lowAngularXLimit = newJoint.highAngularXLimit = spring;
                    }
                    else
                    {
                        newJoint.angularXMotion = ConfigurableJointMotion.Locked;
                    }
                    newJoint.angularYMotion = ConfigurableJointMotion.Locked;
                    newJoint.angularZMotion = ConfigurableJointMotion.Locked;
                    //newJoint.anchor = rotateJoint ? rotatePivot : origTranslation;
                    newJoint.anchor = rotateJoint ? rotatePivot : Vector3.zero;

                    newJoint.projectionMode = JointProjectionMode.PositionAndRotation;
                    newJoint.projectionDistance = 0;
                    newJoint.projectionAngle = 0;

                    newJoint.connectedBody = parent.Rigidbody;
                    attachJoint = newJoint;
                    gotOrig = true;
                    return true;
                }
            }
            else
            {
                gotOrig = true;
                return true;
            }
        }
        return false;
    }
コード例 #54
0
 private void INTERNAL_get_highTwistLimit(out SoftJointLimit value);
コード例 #55
0
 private void INTERNAL_get_swing2Limit(out SoftJointLimit value);
コード例 #56
0
 private void INTERNAL_set_highTwistLimit(ref SoftJointLimit value);
コード例 #57
0
	void BuildJoints ()
	{
		foreach (BoneInfo bone in bones)
		{
			if (bone.parent == null)
				continue;
			
			CharacterJoint joint = (CharacterJoint)bone.anchor.gameObject.AddComponent <CharacterJoint>();
			bone.joint = joint;
			
			// Setup connection and axis
			joint.axis = CalculateDirectionAxis (bone.anchor.InverseTransformDirection(bone.axis));
			joint.swingAxis = CalculateDirectionAxis (bone.anchor.InverseTransformDirection(bone.normalAxis));
			joint.anchor = Vector3.zero;
			joint.connectedBody = bone.parent.anchor.GetComponent<Rigidbody>();
			
			// Setup limits			
			SoftJointLimit limit = new SoftJointLimit ();
			
			limit.limit = bone.minLimit;
			joint.lowTwistLimit = limit;
			
			limit.limit = bone.maxLimit;
			joint.highTwistLimit = limit;
			
			limit.limit = bone.swingLimit;
			joint.swing1Limit = limit;
			
			limit.limit = 0;
			joint.swing2Limit = limit;
            joint.enableProjection = enableProjection;
		}
	}
コード例 #58
0
 private void INTERNAL_get_swing2Limit(out SoftJointLimit value);
コード例 #59
0
		private extern void INTERNAL_get_highAngularXLimit(out SoftJointLimit value);
コード例 #60
0
 private extern void set_highTwistLimit_Injected(ref SoftJointLimit value);