コード例 #1
0
ファイル: Trapdoor.cs プロジェクト: utzstauder/blink
    void Awake()
    {
        numberOfStates = 2;

        leftLimits = leftDoor.limits;
        rightLimits = rightDoor.limits;
    }
コード例 #2
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.JointLimits o;
         o = new UnityEngine.JointLimits();
         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
 }
コード例 #3
0
 void setLimits(HingeJoint joint, JointLimits limits)
 {
     limits.min = joint.angle;
     limits.max = joint.angle;
     joint.limits = limits;
     joint.useLimits = true;
 }
コード例 #4
0
        /// <summary>
        /// Read the data using the reader.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public override object Read(ISaveGameReader reader)
        {
            UnityEngine.JointLimits jointLimits = new UnityEngine.JointLimits();
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "min":
                    jointLimits.min = reader.ReadProperty <System.Single> ();
                    break;

                case "max":
                    jointLimits.max = reader.ReadProperty <System.Single> ();
                    break;

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

                case "bounceMinVelocity":
                    jointLimits.bounceMinVelocity = reader.ReadProperty <System.Single> ();
                    break;

                case "contactDistance":
                    jointLimits.contactDistance = reader.ReadProperty <System.Single> ();
                    break;
                }
            }
            return(jointLimits);
        }
コード例 #5
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.JointLimits jointLimits = (UnityEngine.JointLimits)value;
     writer.WriteProperty("min", jointLimits.min);
     writer.WriteProperty("max", jointLimits.max);
     writer.WriteProperty("bounciness", jointLimits.bounciness);
     writer.WriteProperty("bounceMinVelocity", jointLimits.bounceMinVelocity);
     writer.WriteProperty("contactDistance", jointLimits.contactDistance);
 }
コード例 #6
0
    static public int set_maxBounce(IntPtr l)
    {
        UnityEngine.JointLimits o = (UnityEngine.JointLimits)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.maxBounce = v;
        setBack(l, o);
        return(0);
    }
コード例 #7
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointLimits o;
         o = new UnityEngine.JointLimits();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #8
0
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.JointLimits o;
			o=new UnityEngine.JointLimits();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
コード例 #9
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointLimits o;
         o = new UnityEngine.JointLimits();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #10
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointLimits o;
         o=new UnityEngine.JointLimits();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
コード例 #11
0
ファイル: DetachablePart.cs プロジェクト: OSW-team/Project-4
    public void Detach(bool makeJoint)
    {
        if (!detached)
        {
            detached = true;
            tr.parent = null;
            rb = gameObject.AddComponent<Rigidbody>();
            rb.mass = mass;
            rb.drag = drag;
            rb.angularDrag = angularDrag;

            if (parentBody)
            {
                parentBody.mass -= mass;
                rb.velocity = parentBody.GetPointVelocity(tr.position);
                rb.angularVelocity = parentBody.angularVelocity;

                //Pick a random hinge joint to use
                if (makeJoint && joints.Length > 0)
                {
                    PartJoint chosenJoint = joints[Random.Range(0, joints.Length)];
                    initialAnchor = chosenJoint.hingeAnchor;
                    displacedAnchor = initialAnchor;

                    hinge = gameObject.AddComponent<HingeJoint>();
                    hinge.autoConfigureConnectedAnchor = false;
                    hinge.connectedBody = parentBody;
                    hinge.anchor = chosenJoint.hingeAnchor;
                    hinge.axis = chosenJoint.hingeAxis;
                    hinge.connectedAnchor = initialPos + chosenJoint.hingeAnchor;
                    hinge.enableCollision = false;
                    hinge.useLimits = chosenJoint.useLimits;

                    JointLimits limits = new JointLimits();
                    limits.min = chosenJoint.minLimit;
                    limits.max = chosenJoint.maxLimit;
                    limits.bounciness = chosenJoint.bounciness;
                    hinge.limits = limits;
                    hinge.useSpring = chosenJoint.useSpring;

                    JointSpring spring = new JointSpring();
                    spring.targetPosition = chosenJoint.springTargetPosition;
                    spring.spring = chosenJoint.springForce;
                    spring.damper = chosenJoint.springDamper;
                    hinge.spring = spring;
                    hinge.breakForce = breakForce;
                    hinge.breakTorque = breakForce;
                }
            }
        }
    }
コード例 #12
0
ファイル: angleDetermine.cs プロジェクト: Alexspayne/GA-Arm
 // Use this for initialization
 void Start()
 {
     Debug.Log("Script Started");
     hinge = gameObject.GetComponent<HingeJoint>();
     limitRangeIndex = 0;
     increment = 1;
     delay = 0.01f;
     //Debug.Log("limits.max: " + limits.max + " limits.min: " + limits.min);
     limits = hinge.limits;
     limits.max = limits.min + 1;
     hinge.limits = limits;
     //Debug.Log("limits.max: " + limits.max + " limits.min: " + limits.min);
     //		Debug.Log("End of Start() Method");
 }
コード例 #13
0
 static void HingeJoint_limits(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.HingeJoint _this = (UnityEngine.HingeJoint)vc.csObj;
         var result = _this.limits;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.JointLimits arg0  = (UnityEngine.JointLimits)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.HingeJoint  _this = (UnityEngine.HingeJoint)vc.csObj;
         _this.limits = arg0;
     }
 }
コード例 #14
0
 static void JointLimits_maxBounce(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.JointLimits _this = (UnityEngine.JointLimits)vc.csObj;
         var result = _this.maxBounce;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single           arg0  = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.JointLimits _this = (UnityEngine.JointLimits)vc.csObj;
         _this.maxBounce = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
コード例 #15
0
	private HingeJoint createHingeJoint(GameObject parent) {
		HingeJoint hingeJoint = parent.AddComponent(typeof(HingeJoint)) as HingeJoint;
		hingeJoint.anchor = new Vector3(0f, 0f, 0f);
		hingeJoint.axis = new Vector3(0f, 0f, 1f);
		hingeJoint.breakForce = breakForce;
		hingeJoint.useLimits = true;
		
		JointLimits jointLimits = new JointLimits();
		jointLimits.min = 0f;
		jointLimits.max = 0f;
		jointLimits.minBounce = 0f;
		jointLimits.maxBounce = 0f;
		
		hingeJoint.limits = jointLimits;
		
		return hingeJoint;
	}
コード例 #16
0
ファイル: Flipper.cs プロジェクト: jamiebclark/Pinball
    // Update is called once per frame
    void Update()
    {
        JointSpring spring = new JointSpring();
        spring.spring = strength;
        spring.damper = damper;

        if (Input.GetButton(inputButtonName)) {
            Debug.Log(inputButtonName + " Pressed");
            spring.targetPosition = pressedPosition;
        } else {
            spring.targetPosition = restPosition;
        }
        hingeJoint.spring = spring;

        _jointLimits = hingeJoint.limits;
        _jointLimits.min = restPosition;
        _jointLimits.max = pressedPosition;
        _jointLimits.minBounce = 0.02f;
        _jointLimits.maxBounce = 0.02f;
    }
コード例 #17
0
ファイル: Balance.cs プロジェクト: Yann3D/ROOL
    void Start()
    {
        m_hingeJoint = gameObject.GetComponent<HingeJoint>();
        m_hingeJoint.useMotor = true;
        m_hingeJoint.useLimits = true;
        m_hingeJoint.connectedAnchor = Vector3.zero;

        motor = m_hingeJoint.motor;
        limits = m_hingeJoint.limits;

        motor.force = 75;
        motor.targetVelocity = m_inactiveRotationSpeed;

        limits.min = 0;
        limits.max = Mathf.Max(m_minAngle, m_maxAngle);
        limits.min = Mathf.Min(m_minAngle, m_maxAngle);

        m_hingeJoint.motor = motor;
        m_hingeJoint.limits = limits;
    }
コード例 #18
0
 static public int get_maxBounce(IntPtr l)
 {
     UnityEngine.JointLimits o = (UnityEngine.JointLimits)checkSelf(l);
     pushValue(l, o.maxBounce);
     return(1);
 }
コード例 #19
0
    public override void BuildGamePieceComponents()
    {
        //Debug.Log ("BuildGamePieceComponents()");
        GOtargetSphere.AddComponent<GamePiecePhysXTestsBall>().InitGamePiece();
        GOtargetSphere.AddComponent<Rigidbody>().useGravity = false;
        //GOtargetSphere.GetComponent<Rigidbody>()

        Material segmentMaterial = new Material (Shader.Find("Diffuse"));
        for(int w = 0; w < numberOfSegments; w++) {
            GOwormSegments[w].AddComponent<GamePiecePhysXWormSegment>().InitGamePiece();
            GOwormSegments[w].GetComponent<Renderer>().material = segmentMaterial;
            GOwormSegments[w].AddComponent<Rigidbody>().useGravity = false;

            if(w < (numberOfSegments - 1)) {  // if not the final 'Tail' segment:

            }
            if(w > 0) {  // if not the first root segment:
                HingeJoint hingeJoint = GOwormSegments[w-1].AddComponent<HingeJoint>();
                hingeJoint.autoConfigureConnectedAnchor = false;
                hingeJoint.connectedBody = GOwormSegments[w].GetComponent<Rigidbody>(); // connected bod of previous segment is THIS segment
                hingeJoint.anchor = new Vector3(0.5f, 0f, 0f);
                if(w % 2 == 0) {
                    hingeJoint.axis = new Vector3(0f, 0f, 1f);
                }
                else {
                    hingeJoint.axis = new Vector3(0f, 1f, 0f);
                }
                hingeJoint.connectedAnchor = new Vector3(-0.5f, 0f, 0f);
                JointLimits jointLimits = new JointLimits();
                jointLimits.max = armSegmentMaxBend;
                jointLimits.min = -armSegmentMaxBend;
                hingeJoint.limits = jointLimits;
                hingeJoint.useLimits = true;
                hingeJoint.useMotor = true;
                JointMotor motor = new JointMotor();
                motor.force = jointMotorForce;
                hingeJoint.motor = motor;
            }

        }
        piecesBuilt = true;
    }
コード例 #20
0
 private extern void INTERNAL_set_limits(ref JointLimits value);
コード例 #21
0
    void CreateHingeChain()
    {
        var utilBoneArr = utilityBone.GetComponentsInChildren<SkeletonUtilityBone>();

        foreach (var utilBone in utilBoneArr) {
            AttachRigidbody(utilBone);
        }

        utilityBone.GetComponent<Rigidbody>().isKinematic = true;

        foreach (var utilBone in utilBoneArr) {
            if (utilBone == utilityBone)
                continue;

            utilBone.mode = SkeletonUtilityBone.Mode.Override;

            HingeJoint joint = utilBone.gameObject.AddComponent<HingeJoint>();
            joint.axis = Vector3.forward;
            joint.connectedBody = utilBone.transform.parent.GetComponent<Rigidbody>();
            joint.useLimits = true;
            JointLimits limits = new JointLimits();
            limits.min = -20;
            limits.max = 20;
            joint.limits = limits;
            utilBone.GetComponent<Rigidbody>().mass = utilBone.transform.parent.GetComponent<Rigidbody>().mass * 0.75f;
        }
    }
コード例 #22
0
ファイル: KASModuleRotor.cs プロジェクト: ErzengelLichtes/KAS
 public void ResetLimitsConfig()
 {
     JointLimits lmt = new JointLimits();
     lmt.min = limitMin;
     lmt.minBounce = limitMinBounce;
     lmt.max = limitMax;
     lmt.maxBounce = limitMaxBounce;
     hingeJnt.limits = lmt;
 }
コード例 #23
0
ファイル: KASModuleRotor.cs プロジェクト: ErzengelLichtes/KAS
 private void MotorStop()
 {
     KAS_Shared.DebugLog("MotorStart(Rotor) - Stop motor...");
     if (!hingeJnt) return;
     //Sound
     if (hingeJnt.motor.targetVelocity != 0)
     {
         fxSndMotorStop.audio.Play();
     }
     if (fxSndMotor.audio.isPlaying) fxSndMotor.audio.Stop();
     //Motor config
     JointMotor mtr = new JointMotor();
     mtr.force = force;
     mtr.freeSpin = freeSpin;
     mtr.targetVelocity = 0;
     hingeJnt.motor = mtr;
     //Limit config (workaround, motor don't seem to keep position correctly with mass attached)
     JointLimits lmt = new JointLimits();
     lmt.min = hingeJnt.angle - stopOffset;
     lmt.minBounce = 0;
     lmt.max = hingeJnt.angle + stopOffset;
     lmt.maxBounce = 0;
     hingeJnt.limits = lmt;
     //Misc
     hingeJnt.useLimits = true;
     hingeJnt.useSpring = false;
     hingeJnt.useMotor = false;//true
     rotorActivated = false;
     rotorGoingTo = false;
     stateField = "Idle";
 }
コード例 #24
0
ファイル: KartPhysics.cs プロジェクト: rjho/TraX
    //Links together the components of the kart
    void connectKartComponents()
    {
        //Create connections
        leftAxleHinge = leftAxle.gameObject.AddComponent<HingeJoint> ();
        leftAxleHinge.axis = new Vector3 (0, 0, 1);
        leftAxleHinge.connectedBody = chassisRigidBody;
        leftAxleHinge.useLimits = true;

        JointLimits limit = new JointLimits ();
        limit.min = -frontWheelRange/2;
        limit.max = frontWheelRange/2;
        leftAxleHinge.limits = limit;

        rightAxleHinge = rightAxle.gameObject.AddComponent<HingeJoint> ();
        rightAxleHinge.axis = new Vector3 (0, 0, 1);
        rightAxleHinge.connectedBody = chassisRigidBody;
        rightAxleHinge.useLimits = true;

        rightAxleHinge.limits = limit;

        rearAxleHinge = rearAxle.gameObject.AddComponent<HingeJoint> ();
        rearAxleHinge.axis = new Vector3 (1, 0, 0);
        rearAxleHinge.connectedBody = chassisRigidBody;
        rearAxleHinge.useLimits = true;

        limit = new JointLimits ();
        limit.min = -rearWheelRange/2;
        limit.max = rearWheelRange/2;
        rearAxleHinge.limits = limit;

        //Hinge joints for wheels
        flDrive = leftAxleWheel.gameObject.AddComponent<HingeJoint> ();
        flDrive.connectedBody = leftPivotRB;

        frDrive = rightAxleWheel.gameObject.AddComponent<HingeJoint> ();
        frDrive.connectedBody = rightPivotRB;

        rlDrive = rearAxleLeft.gameObject.AddComponent<HingeJoint> ();
        rlDrive.connectedBody = rearAxleRigidBody;
        rlDrive.useMotor = true;

        rrDrive = rearAxleRight.gameObject.AddComponent<HingeJoint> ();
        rrDrive.connectedBody = rearAxleRigidBody;
        rrDrive.useMotor = true;

        //Hinge joints for steering
        JointLimits limitSteer = new JointLimits ();
        limitSteer.min = -maxTurnRadius;
        limitSteer.max = maxTurnRadius;

        leftSteer = leftPivot.gameObject.AddComponent<HingeJoint> ();
        leftSteer.connectedBody = leftAxleRigidBody;
        leftSteer.axis = new Vector3 (0, 1, 0);
        leftSteer.useLimits = true;
        leftSteer.limits = limitSteer;

        rightSteer = rightPivot.gameObject.AddComponent<HingeJoint> ();
        rightSteer.connectedBody = rightAxleRigidBody;
        rightSteer.axis = new Vector3 (0, 1, 0);
        rightSteer.useLimits = true;
        rightSteer.limits = limitSteer;

        //Power steering
        leftSteer.useMotor = true;
        rightSteer.useMotor = true;

        //Shocks (Use spring joint here if needed, probably spring in axle will work)
        rearAxleHinge.useSpring = true;
        JointSpring spring = new JointSpring ();
        spring.spring = rearShockForce;
        spring.damper = rearShockDamp;
        rearAxleHinge.spring = spring;

        leftAxleHinge.useSpring = true;
        spring = new JointSpring ();
        spring.spring = frontShockForce;
        spring.damper = frontShockDamp;
        leftAxleHinge.spring = spring;

        rightAxleHinge.useSpring = true;
        rightAxleHinge.spring = spring;
    }
コード例 #25
0
 void Start()
 {
     if(!Upper)
     {
     SpringRigidbody.hingeJoint.useLimits = true;
     JointLimits springLimits = new JointLimits();
     springLimits.min = WheelParameters.SpringMin;
     springLimits.max = WheelParameters.SpringMax;
     SpringRigidbody.hingeJoint.limits = springLimits;
     }
     SetSpringParameters ();
 }
コード例 #26
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;
 }
コード例 #27
0
    public void Apply()
    {
        isActive = true;
        skeleton = skeletonAnim.Skeleton;
        mix = 1;

        var ragdollRootBone = skeleton.FindBone(startingBoneName);
        startingBone = ragdollRootBone;
        RecursivelyCreateBoneProxies(ragdollRootBone);

        rootRigidbody = boneTable[ragdollRootBone].GetComponent<Rigidbody>();
        rootRigidbody.isKinematic = pinStartBone;

        rootRigidbody.mass = rootMass;

        List<Collider> boneColliders = new List<Collider>();

        foreach (var pair in boneTable) {
            var b = pair.Key;
            var t = pair.Value;
            Bone parentBone = null;
            Transform parentTransform = transform;

            boneColliders.Add(t.GetComponent<Collider>());

            if (b != startingBone) {
                parentBone = b.Parent;
                parentTransform = boneTable[parentBone];
            } else {
                ragdollRoot = new GameObject("RagdollRoot").transform;
                ragdollRoot.parent = transform;

                if (b == skeleton.RootBone) {
                    ragdollRoot.localPosition = new Vector3(b.WorldX, b.WorldY, 0);
                    ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetCompensatedRotationIK(b));
                    parentTransform = ragdollRoot;
                } else {
                    ragdollRoot.localPosition = new Vector3(b.Parent.WorldX, b.Parent.WorldY, 0);
                    ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetCompensatedRotationIK(b.Parent));
                    parentTransform = ragdollRoot;
                }

                rootOffset = t.position - transform.position;
            }

            var rbParent = parentTransform.GetComponent<Rigidbody>();

            if (rbParent != null) {
                var joint = t.gameObject.AddComponent<HingeJoint>();
                joint.connectedBody = rbParent;
                Vector3 localPos = parentTransform.InverseTransformPoint(t.position);
                localPos.x *= 1;
                joint.connectedAnchor = localPos;
                joint.axis = Vector3.forward;
                joint.GetComponent<Rigidbody>().mass = joint.connectedBody.mass * massFalloffFactor;
                JointLimits limits = new JointLimits();
                limits.min = -rotationLimit;
                limits.max = rotationLimit;
                joint.limits = limits;
                joint.useLimits = true;
                joint.enableCollision = enableJointCollision;
            }
        }

        for (int x = 0; x < boneColliders.Count; x++) {
            for (int y = 0; y < boneColliders.Count; y++) {
                if (x == y) continue;
                Physics.IgnoreCollision(boneColliders[x], boneColliders[y]);
            }
        }

        var utilityBones = GetComponentsInChildren<SkeletonUtilityBone>();
        if (utilityBones.Length > 0) {
            List<string> destroyedUtilityBoneNames = new List<string>();
            foreach (var ub in utilityBones) {
                if (ub.mode == SkeletonUtilityBone.Mode.Override) {
                    destroyedUtilityBoneNames.Add(ub.gameObject.name);
                    Destroy(ub.gameObject);
                }
            }

            if (destroyedUtilityBoneNames.Count > 0) {
                string msg = "Destroyed Utility Bones: ";
                for (int i = 0; i < destroyedUtilityBoneNames.Count; i++) {
                    msg += destroyedUtilityBoneNames[i];
                    if (i != destroyedUtilityBoneNames.Count - 1) {
                        msg += ",";
                    }
                }
                Debug.LogWarning(msg);
            }
        }

        if (disableIK) {
            foreach (IkConstraint ik in skeleton.IkConstraints) {
                ik.Mix = 0;
            }
        }

        skeletonAnim.UpdateWorld += UpdateWorld;
    }
コード例 #28
0
	void CreateRope(Rigidbody lastPillar, Rigidbody nextPillar) {
		JointLimits myLimits = new JointLimits();
		myLimits.min = -1f;
		myLimits.max = 1f;
		myLimits.maxBounce = 0f;
		myLimits.minBounce = 0f;
		
		Vector3 pointA = lastPillar.transform.position + ((lastPillar.transform.up * lastPillar.transform.localScale.y * 0.95f) / 1f)
			+ ((lastPillar.transform.right * lastPillar.transform.localScale.x) / 2f);
		
		Vector3 pointB = nextPillar.transform.position + ((nextPillar.transform.up * nextPillar.transform.localScale.y * 0.95f) / 1f)
			- ((nextPillar.transform.right * nextPillar.transform.localScale.x) / 2f);
		
		Vector3 nextPartVector = (pointB - pointA) / numberOfRopeParts;
		Vector3 startPoint = pointA;
		float partWidth = (nextPartVector.magnitude / 2f) * 1.3f;
		
		Rigidbody lastPart = null;
		for (int j = 0; j < numberOfRopeParts; j++) {
			Vector3 centerPoint = startPoint + (nextPartVector / 2f);
			
			Rigidbody newRope = Instantiate(ropePartPrefab) as Rigidbody;
			newRope.isKinematic = true;
			newRope.transform.position = centerPoint;

			rigidbodies.Add(newRope);
			
			float myScale = newRope.transform.localScale.y / partWidth;
			newRope.transform.localScale /= myScale;
			
			startPoint += nextPartVector;
			LookAtUp(newRope.transform, startPoint);
			
			HingeJoint ropePartJoint = createHingeJoint(newRope.gameObject);
			ropePartJoint.useLimits = true;
			ropePartJoint.limits = myLimits;
			ropePartJoint.axis = new Vector3(1f, 0f, 0f);
			ropePartJoint.anchor = new Vector3(0f, -1f, 0f);
			ropePartJoint.breakForce = ropeBreakForce;
			ropePartJoint.connectedBody = lastPart ?? lastPillar;
			
			lastPart = newRope;
		}
		
		HingeJoint lastRopePartJoint = createHingeJoint(lastPart.gameObject);
		lastRopePartJoint.useLimits = true;
		lastRopePartJoint.limits = myLimits;
		lastRopePartJoint.axis = new Vector3(1f, 0f, 0f);
		lastRopePartJoint.anchor = new Vector3(0f, 1f, 0f);
		lastRopePartJoint.breakForce = ropeBreakForce;
		lastRopePartJoint.connectedBody = nextPillar;
	}
コード例 #29
0
 // Conversion from JointLimit and JointSpring to SoftJointLimitSpring
 private static SoftJointLimitSpring ConvertToSoftJointLimitSpring(JointLimits src, JointSpring spring, bool useSpring)
 {
     SoftJointLimitSpring limitSpring = new SoftJointLimitSpring();
     limitSpring.damper = useSpring? spring.damper: 0f;
     limitSpring.spring = useSpring? spring.spring: 0f;
     return limitSpring;
 }
コード例 #30
0
		private extern void INTERNAL_get_limits(out JointLimits value);
コード例 #31
0
ファイル: KASModuleRotor.cs プロジェクト: Kerbas-ad-astra/KAS
 public void ResetLimitsConfig()
 {
     var lmt = new JointLimits();
     lmt.min = limitMin;
     lmt.max = limitMax;
     lmt.bounciness = limitMinBounce;
     hingeJnt.limits = lmt;
 }
コード例 #32
0
 private extern void INTERNAL_get_limits(out JointLimits value);
コード例 #33
0
		private extern void INTERNAL_set_limits(ref JointLimits value);
コード例 #34
0
    public override void BuildGamePieces()
    {
        // COMPONENTS ONLY RIGHT NOW!
        //Debug.Log ("Build GamePieces()");
        GOtargetSphere.AddComponent<GamePiecePhysXTestsBall>().InitGamePiece();
        GOtargetSphere.GetComponent<Rigidbody>().useGravity = false;
        GOtargetSphere.transform.SetParent(ArenaGroup.arenaGroupStatic.gameObject.transform);

        for(int w = 0; w < numberOfSegments; w++) {
            GOwormSegments[w].transform.localScale = new Vector3(wormSegmentArray_Length[w][0], wormSegmentThickness, wormSegmentThickness*2f);
            //GOwormSegments[w].transform.localPosition = new Vector3(wormSegmentArray_PosX[w][0], wormSegmentArray_PosY[w][0], wormSegmentArray_PosZ[w][0]); // RE-EVALUATE!!!
            GOwormSegments[w].transform.position = new Vector3(wormSegmentArray_PosX[w][0], wormSegmentArray_PosY[w][0], wormSegmentArray_PosZ[w][0]); // RE-EVALUATE!!!
            GOwormSegments[w].transform.localRotation = Quaternion.identity;
            Debug.Log ("BuildGamePieces() position: " + GOwormSegments[w].transform.position.ToString());

            GOwormSegments[w].AddComponent<GamePiecePhysXWormSegment>().InitGamePiece();
            GOwormSegments[w].GetComponent<Rigidbody>().useGravity = false;
            // Set starting position:
            //Vector3 newPos = new Vector3(wormSegmentArray_PosX[w][0], wormSegmentArray_PosY[w][0], wormSegmentArray_PosZ[w][0]);
            //GOwormSegments[w].GetComponent<Rigidbody>().position = newPos;
            //Debug.Log ("Build GamePieces() newPos: " + newPos.ToString());
            //GOwormSegments[w].GetComponent<Rigidbody>().velocity = new Vector3(0f, 0f, 0f);
            //GOwormSegments[w].GetComponent<Rigidbody>().angularVelocity = new Vector3(0f, 0f, 0f);
            if(w < (numberOfSegments - 1)) {  // if not the final 'Tail' segment:

            }
            if(w > 0) {  // if not the first root segment:
                HingeJoint hingeJoint = GOwormSegments[w-1].AddComponent<HingeJoint>();
                hingeJoint.autoConfigureConnectedAnchor = false;
                hingeJoint.connectedBody = GOwormSegments[w].GetComponent<Rigidbody>(); // connected bod of previous segment is THIS segment
                hingeJoint.anchor = new Vector3(0.5f, 0f, 0f);
                if(w % 2 == 0) {
                    hingeJoint.axis = new Vector3(0f, 0f, 1f);
                }
                else {
                    hingeJoint.axis = new Vector3(0f, 1f, 0f);
                }
                hingeJoint.connectedAnchor = new Vector3(-0.5f, 0f, 0f);
                JointLimits jointLimits = new JointLimits();
                jointLimits.max = armSegmentMaxBend;
                jointLimits.min = -armSegmentMaxBend;
                hingeJoint.limits = jointLimits;
                hingeJoint.useLimits = true;
                hingeJoint.useMotor = true;
                JointMotor motor = new JointMotor();
                motor.force = jointMotorForce;
                hingeJoint.motor = motor;

            }
            GOwormSegments[w].transform.SetParent(ArenaGroup.arenaGroupStatic.gameObject.transform);
            Material segmentMaterial = new Material (Shader.Find("Diffuse"));
            GOwormSegments[w].GetComponent<Renderer>().material = segmentMaterial;
        }

        piecesBuilt = true;
    }