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.JointMotor o;
         o = new UnityEngine.JointMotor();
         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
파일: PopStick.cs 프로젝트: BeForU/Hi-
 // Use this for initialization
 void Start()
 {
     //moter = joint.motor;
     joint = GetComponent<HingeJoint>();
     moter = new JointMotor();
     moter.force = 3000;
 }
예제 #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.JointMotor jointMotor = (UnityEngine.JointMotor)value;
     writer.WriteProperty("targetVelocity", jointMotor.targetVelocity);
     writer.WriteProperty("force", jointMotor.force);
     writer.WriteProperty("freeSpin", jointMotor.freeSpin);
 }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     hinge = GetComponent<HingeJoint> ();
     moter = new JointMotor ();
     hinge.useMotor = true;
     moter.force = 100000.0f;
 }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        //	speed = 10.0f;
        //	rotVec = Vector3.zero;

        hingeJoint = GetComponent<HingeJoint> ();
        moter = new JointMotor ();
        moter.force = 100;
    }
예제 #6
0
    static public int set_force(IntPtr l)
    {
        UnityEngine.JointMotor o = (UnityEngine.JointMotor)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.force = v;
        setBack(l, o);
        return(0);
    }
예제 #7
0
    static public int set_targetVelocity(IntPtr l)
    {
        UnityEngine.JointMotor o = (UnityEngine.JointMotor)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.targetVelocity = v;
        setBack(l, o);
        return(0);
    }
예제 #8
0
    static public int set_freeSpin(IntPtr l)
    {
        UnityEngine.JointMotor o = (UnityEngine.JointMotor)checkSelf(l);
        bool v;

        checkType(l, 2, out v);
        o.freeSpin = v;
        setBack(l, o);
        return(0);
    }
예제 #9
0
    void SetMotorParameters()
    {
        oldVelocity = WheelParameters.Velocity;
        oldMotorForce = WheelParameters.MotorForce;

        WheelRigidbody.hingeJoint.useMotor = true;
        JointMotor wheelMotor = new JointMotor();
        wheelMotor.targetVelocity = WheelParameters.Velocity/Radius;
        wheelMotor.force = WheelParameters.MotorForce;
        WheelRigidbody.hingeJoint.motor = wheelMotor;
    }
예제 #10
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointMotor o;
         o = new UnityEngine.JointMotor();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.JointMotor o;
			o=new UnityEngine.JointMotor();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
예제 #12
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointMotor o;
         o = new UnityEngine.JointMotor();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
예제 #13
0
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointMotor o;
         o=new UnityEngine.JointMotor();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
예제 #14
0
 void OnEnable()
 {
     door_motor = new JointMotor();
     door_motor.force = 10;
     if(!is_open)
     {
         door_motor.targetVelocity = open_velocity;
         is_open = true;
     }
     else if(is_open)
     {
         door_motor.targetVelocity = close_velocity;
         is_open = false;
     }
 }
// fields

// properties
    static void HingeJoint_motor(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.HingeJoint _this = (UnityEngine.HingeJoint)vc.csObj;
            var result = _this.motor;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.JointMotor arg0  = (UnityEngine.JointMotor)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.HingeJoint _this = (UnityEngine.HingeJoint)vc.csObj;
            _this.motor = arg0;
        }
    }
 static void JointMotor_force(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.JointMotor _this = (UnityEngine.JointMotor)vc.csObj;
         var result = _this.force;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single          arg0  = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.JointMotor _this = (UnityEngine.JointMotor)vc.csObj;
         _this.force = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
 static void JointMotor_freeSpin(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.JointMotor _this = (UnityEngine.JointMotor)vc.csObj;
         var result = _this.freeSpin;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean         arg0  = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.JointMotor _this = (UnityEngine.JointMotor)vc.csObj;
         _this.freeSpin = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
예제 #18
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;
    }
예제 #19
0
        /// <summary>
        /// Read the data using the reader.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public override object Read(ISaveGameReader reader)
        {
            UnityEngine.JointMotor jointMotor = new UnityEngine.JointMotor();
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "targetVelocity":
                    jointMotor.targetVelocity = reader.ReadProperty <System.Single> ();
                    break;

                case "force":
                    jointMotor.force = reader.ReadProperty <System.Single> ();
                    break;

                case "freeSpin":
                    jointMotor.freeSpin = reader.ReadProperty <System.Boolean> ();
                    break;
                }
            }
            return(jointMotor);
        }
 // Use this for initialization
 void Start()
 {
     //
     baseJoint.useMotor = true;
     armJoint.useMotor = true;
     bucketJoint.useMotor = true;
     unionJoint.useMotor = true;
     baseMotor = baseJoint.motor;
     baseMotor.force = 100;
     armMotor = armJoint.motor;
     armMotor.force = 100;
     bucketMotor = bucketJoint.motor;
     bucketMotor.force = 100;
     unionMotor = unionJoint.motor;
     unionMotor.force = 200;
     if(useLimits) {
         setLimits(baseJoint, baseLimits);
         setLimits(armJoint, armLimits);
         setLimits(bucketJoint, bucketLimits);
     }
     //
     VRPNEventManager.StartListeningTracker(VRPNManager.Tracker_Types.vrpn_Tracker_RazerHydra, VRPNDeviceConfig.Device_Names.Tracker0, trackerUpdate);
 }
예제 #21
0
 static public int get_targetVelocity(IntPtr l)
 {
     UnityEngine.JointMotor o = (UnityEngine.JointMotor)checkSelf(l);
     pushValue(l, o.targetVelocity);
     return(1);
 }
예제 #22
0
    private static void lukeUseTheForce(int index)
    {
        //use angle of the joints and hook, or angle of the motors
        List<double> inputs = new List<double> ();
        inputs.Add ((double)(joints[index].transform.eulerAngles.z * piOver180));
        inputs.Add ((double)(hooks[index].transform.eulerAngles.z * piOver180));
        inputs.Add ((double)(joints2[index].transform.eulerAngles.z * piOver180));
        inputs.Add ((double)(hooks2[index].transform.eulerAngles.z * piOver180));
        //inputs.Add ((double)(topCyl [index].transform.position.y - botCyl [index].transform.position.y));

        List<double> outputs = networks [index].calculateOutput (inputs);
        //botCyl [index].GetComponent<Rigidbody> ().velocity = new Vector3 ((float)outputs [0], 0.0f, 0.0f);
        JointMotor jm = new JointMotor();
        jm.force = 3000.0f;
        jm.targetVelocity = 60.0f * ((float)outputs[0]);

        JointMotor hm = new JointMotor();
        hm.force = 3000.0f;
        hm.targetVelocity = 60.0f * ((float)outputs[1]);

        joints[index].GetComponent<HingeJoint>().motor = jm;
        hooks[index].GetComponent<HingeJoint>().motor = hm;

        JointMotor jm2 = new JointMotor();
        jm2.force = 3000.0f;
        jm2.targetVelocity = 60.0f * ((float)outputs[2]);

        JointMotor hm2 = new JointMotor();
        hm2.force = 3000.0f;
        hm2.targetVelocity = 60.0f * ((float)outputs[3]);

        joints2[index].GetComponent<HingeJoint>().motor = jm2;
        hooks2[index].GetComponent<HingeJoint>().motor = hm2;
    }
예제 #23
0
    public void initEverything(int index)
    {
        int x = index / 13;
        int z = index % 13;
        float sx = ((float)x) * 9.0f;
        float sz = 0.0f;
        if (x % 2 == 0) {
            sz = ((float)z) * 4.5f;
        }
        else if (x % 2 == 1) {
            sz = ((float)z) * 4.5f + 2.25f;
        }

        cubes[index] = Instantiate (cubePreFab) as GameObject;
        joints[index] = Instantiate (jointPreFab) as GameObject;
        hooks [index] = Instantiate (hookPreFab) as GameObject;
        joints2[index] = Instantiate (jointPreFab2) as GameObject;
        hooks2 [index] = Instantiate (hookPreFab2) as GameObject;
        wheel1s [index] = Instantiate (wheel1PreFab) as GameObject;
        wheel2s [index] = Instantiate (wheel2PreFab) as GameObject;

        /*int posneg = rand.Next (0, 2);
        float tchange = 0.0f;
        if (posneg == 0) {
            tchange = 0.02f;
        } else {
            tchange = -0.02f;
        }*/
        cubesStartX [index] = cubes [index].transform.position.x + sx;
        cubes[index].transform.position = new Vector3 (cubes[index].transform.position.x + sx, cubes[index].transform.position.y, cubes[index].transform.position.z + sz);
        joints [index].transform.position = new Vector3 (joints[index].transform.position.x + sx, joints[index].transform.position.y, joints[index].transform.position.z + sz);
        hooks [index].transform.position = new Vector3 (hooks[index].transform.position.x + sx, hooks[index].transform.position.y, hooks[index].transform.position.z + sz);
        joints2 [index].transform.position = new Vector3 (joints2[index].transform.position.x + sx, joints2[index].transform.position.y, joints2[index].transform.position.z + sz);
        hooks2 [index].transform.position = new Vector3 (hooks2[index].transform.position.x + sx, hooks2[index].transform.position.y, hooks2[index].transform.position.z + sz);
        wheel1s [index].transform.position = new Vector3 (wheel1s[index].transform.position.x + sx, wheel1s[index].transform.position.y, wheel1s[index].transform.position.z + sz);
        wheel2s [index].transform.position = new Vector3 (wheel2s[index].transform.position.x + sx, wheel2s[index].transform.position.y, wheel2s[index].transform.position.z + sz);

        joints [index].AddComponent <HingeJoint>();
        joints[index].GetComponent<HingeJoint>().connectedBody = cubes [index].GetComponent<Rigidbody> ();
        joints[index].GetComponent<HingeJoint>().anchor = new Vector3 (0.0f, -1.0f, 0.0f);
        joints[index].GetComponent<HingeJoint>().axis = new Vector3 (0.0f, 0.0f, 1.0f);
        joints[index].GetComponent<HingeJoint>().autoConfigureConnectedAnchor = true;
        joints[index].GetComponent<HingeJoint>().useMotor = true;
        JointMotor jm = new JointMotor();
        jm.force = 2000.0f;
        jm.targetVelocity = 0.0f;
        joints[index].GetComponent<HingeJoint>().motor = jm;

        joints2 [index].AddComponent <HingeJoint>();
        joints2[index].GetComponent<HingeJoint>().connectedBody = cubes [index].GetComponent<Rigidbody> ();
        joints2[index].GetComponent<HingeJoint>().anchor = new Vector3 (0.0f, -1.0f, 0.0f);
        joints2[index].GetComponent<HingeJoint>().axis = new Vector3 (0.0f, 0.0f, 1.0f);
        joints2[index].GetComponent<HingeJoint>().autoConfigureConnectedAnchor = true;
        joints2[index].GetComponent<HingeJoint>().useMotor = true;
        JointMotor jm2 = new JointMotor();
        jm2.force = 2000.0f;
        jm2.targetVelocity = 0.0f;
        joints2[index].GetComponent<HingeJoint>().motor = jm2;

        hooks [index].AddComponent<HingeJoint> ();
        hooks[index].GetComponent<HingeJoint>().connectedBody = joints [index].GetComponent<Rigidbody> ();
        hooks[index].GetComponent<HingeJoint>().anchor = new Vector3 (0.0f, 1.0f, 0.0f);
        hooks[index].GetComponent<HingeJoint>().axis = new Vector3 (0.0f, 0.0f, 1.0f);
        hooks[index].GetComponent<HingeJoint>().autoConfigureConnectedAnchor = true;
        hooks[index].GetComponent<HingeJoint>().useMotor = true;

        JointMotor hm = new JointMotor();
        hm.force = 2000.0f;
        hm.targetVelocity = 0.0f;
        hooks[index].GetComponent<HingeJoint>().motor = hm;

        hooks2 [index].AddComponent<HingeJoint> ();
        hooks2[index].GetComponent<HingeJoint>().connectedBody = joints2 [index].GetComponent<Rigidbody> ();
        hooks2[index].GetComponent<HingeJoint>().anchor = new Vector3 (0.0f, 1.0f, 0.0f);
        hooks2[index].GetComponent<HingeJoint>().axis = new Vector3 (0.0f, 0.0f, 1.0f);
        hooks2[index].GetComponent<HingeJoint>().autoConfigureConnectedAnchor = true;
        hooks2[index].GetComponent<HingeJoint>().useMotor = true;

        JointMotor hm2 = new JointMotor();
        hm2.force = 2000.0f;
        hm2.targetVelocity = 0.0f;
        hooks2[index].GetComponent<HingeJoint>().motor = hm2;

        wheel1s [index].AddComponent <HingeJoint>();
        wheel1s[index].GetComponent<HingeJoint>().connectedBody = cubes [index].GetComponent<Rigidbody> ();
        wheel1s[index].GetComponent<HingeJoint>().anchor = new Vector3 (0.0f, 0.0f, 0.0f);
        wheel1s[index].GetComponent<HingeJoint>().axis = new Vector3 (0.0f, 1.0f, 0.0f);
        wheel1s[index].GetComponent<HingeJoint>().autoConfigureConnectedAnchor = true;

        wheel2s [index].AddComponent <HingeJoint>();
        wheel2s[index].GetComponent<HingeJoint>().connectedBody = cubes [index].GetComponent<Rigidbody> ();
        wheel2s[index].GetComponent<HingeJoint>().anchor = new Vector3 (0.0f, 0.0f, 0.0f);
        wheel2s[index].GetComponent<HingeJoint>().axis = new Vector3 (0.0f, 1.0f, 0.0f);
        wheel2s[index].GetComponent<HingeJoint>().autoConfigureConnectedAnchor = true;
    }
예제 #24
0
 private extern void INTERNAL_set_motor(ref JointMotor value);
예제 #25
0
파일: KartPhysics.cs 프로젝트: rjho/TraX
    void driveKart()
    {
        //Accelerate the motor
        JointMotor motor = new JointMotor ();
        motor.force = maxTorque;
        motor.targetVelocity = -maxSpeed*accelerate;

        //Free spin on the motor
        if (accelerate == 0) {
            motor.freeSpin = true;
            motor.force = 0;
        } else {
            motor.freeSpin = false;
        }

        rlDrive.motor = motor;
        rrDrive.motor = motor;

        accelerate = 0;

        //Reverse
        if (reverse != 0) {
            motor = new JointMotor ();
            motor.force = maxTorqueReverse;
            motor.targetVelocity = maxSpeedReverse * reverse;
            motor.freeSpin = false;
            rlDrive.motor = motor;
            rrDrive.motor = motor;

            reverse = 0;
        }

        //Mario kart style spinnout
        if (spinnout > 0) {
            chassisRigidBody.angularVelocity = new Vector3(0, 1000, 0);
            spinnout -= Time.deltaTime*10;
        }

        //Turn the wheels
        motor = new JointMotor ();
        motor.force = 1000;

        if (leftSteer.angle > turning) {
            motor.targetVelocity = -10*(leftSteer.angle-turning);
        }

        else if (leftSteer.angle < turning) {
            motor.targetVelocity = 10*(turning-leftSteer.angle);
        }

        leftSteer.motor = motor;

        if (rightSteer.angle > turning) {
            motor.targetVelocity = -10*(rightSteer.angle-turning);
        }

        else if (rightSteer.angle < turning) {
            motor.targetVelocity = 10*(turning-rightSteer.angle);
        }

        rightSteer.motor = motor;

        //Default the shift position
        GameObject gearShift = drivingPartsRender.transform.FindChild ("shiftRigged").FindChild ("Armature").FindChild ("Armature").FindChild ("Shift").gameObject;//.Rotate (new Vector3 (0, 0, 1), 1);

        if (gearShift.transform.rotation.eulerAngles.z < 30 && accelerate == 0 && reverse == 0) {
            gearShift.transform.Rotate ( new Vector3 (0, 0, 1), 2);
        }

        if (gearShift.transform.rotation.eulerAngles.z > 30 && accelerate == 0 && reverse == 0) {
            gearShift.transform.Rotate ( new Vector3 (0, 0, 1), -2);
        }
    }
예제 #26
0
    void Start()
    {
        var components = GetComponentsInChildren<HingeJoint>();

        foreach (var component in components)
        {
            var hinge = component;
            var motor = new JointMotor();
            motor.targetVelocity = Velocity;
            motor.force = 0f;
            hinge.motor = motor;

            if (component.transform.name.Contains("right"))
            {
                rightWheels.Add(hinge);
            }
            else
            {
                leftWheels.Add(hinge);
            }
        }
    }
예제 #27
0
		private extern void INTERNAL_get_motor(out JointMotor value);
예제 #28
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;
    }
예제 #29
0
 private void MotorStart(motorWay way)
 {
     KAS_Shared.DebugLog("MotorStart(Rotor) - Start motor...");
     if (!hingeJnt) return;
     if (KAS_Shared.RequestPower(this.part, powerDrain))
     {
         //Sound
         if (hingeJnt.motor.targetVelocity == 0)
         {
             fxSndMotorStart.audio.Play();
         }
         if (!fxSndMotor.audio.isPlaying) fxSndMotor.audio.Play();
         //Limit config
         ResetLimitsConfig();
         hingeJnt.useLimits = hasLimit;
         JointMotor mtr = new JointMotor();
         //Motor config
         mtr.force = force;
         mtr.freeSpin = freeSpin;
         if (way == motorWay.Negative)
         {
             if (controlInverted) mtr.targetVelocity = speed;
             else mtr.targetVelocity = -speed;
             stateField = "Going " + negativeWayText;
         }
         if (way == motorWay.Positive)
         {
             if (controlInverted) mtr.targetVelocity = -speed;
             else mtr.targetVelocity = speed;
             stateField = "Going " + positiveWayText;
         }
         hingeJnt.motor = mtr;
         //misc
         hingeJnt.useSpring = false;
         hingeJnt.useMotor = true;
         rotorActivated = true;
     }
     else
     {
         if (this.part.vessel == FlightGlobals.ActiveVessel)
         {
             ScreenMessages.PostScreenMessage(this.part.partInfo.title + " stopped ! Insufficient Power", 5, ScreenMessageStyle.UPPER_CENTER);
         }
         stateField = "Insufficient Power";
     }
 }
 void Awake()
 {
     hinge = GetComponent<HingeJoint>();
     rigidbody = GetComponent<Rigidbody>();
     motor = hinge.motor;
 }
예제 #31
0
 private extern void INTERNAL_get_motor(out JointMotor value);
예제 #32
0
    // Use this for initialization
    void Start()
    {
        baseJoint.useMotor = true;
        armJoint.useMotor = true;
        bucketJoint.useMotor = true;
        unionJoint.useMotor = true;
        baseMotor = baseJoint.motor;
        baseMotor.force = 400;
        armMotor = armJoint.motor;
        armMotor.force = 100;
        bucketMotor = bucketJoint.motor;
        bucketMotor.force = 100;
        unionMotor = unionJoint.motor;
        unionMotor.force = 200;

        excavatorRotationAxisName = "Rotate Excavator";
        baseRotationAxisName = "Rotate Base";
        armRotationAxisName = "Rotate Arm";
        bucketRotationAxisName = "Rotate Bucket";

        /*if(enableLimits) {
            setLimits(baseJoint, baseLimits);
            setLimits(armJoint, armLimits);
            setLimits(bucketJoint, bucketLimits);
        }*/
    }
예제 #33
0
    public override void Tick()
    {
        // Runs the mini-game for a single evaluation step.
        //Debug.Log ("Tick()");
        // THIS IS ALL PRE- PHYS-X!!! ::

        for(int w = 0; w < numberOfSegments; w++) {
            if(GOwormSegments[w].GetComponent<HingeJoint>() != null) {
                JointMotor motor = new JointMotor();
                motor.force = jointMotorForce;
                motor.targetVelocity = wormSegmentArray_MotorTarget[w][0] * jointMotorSpeed;
                GOwormSegments[w].GetComponent<HingeJoint>().motor = motor;
            }
            ApplyViscosityForces(GOwormSegments[w], w, viscosityDrag);
        }

        // FITNESS COMPONENTS!
        Vector3 avgPos = new Vector3(0f, 0f, 0f);
        for(int e = 0; e < numberOfSegments; e++) {
            avgPos += new Vector3(wormSegmentArray_PosX[e][0], wormSegmentArray_PosY[e][0], wormSegmentArray_PosZ[e][0]);
            fitEnergySpent[0] += Mathf.Abs (wormSegmentArray_MotorTarget[e][0])/(float)numberOfSegments;
        }
        avgPos /= (float)numberOfSegments;
        ArenaCameraController.arenaCameraControllerStatic.focusPosition = avgPos;
        Vector3 targetDirection = new Vector3(targetPosX[0] - avgPos.x, targetPosY[0] - avgPos.y, targetPosZ[0] - avgPos.z);
        float distToTarget = targetDirection.magnitude;
        fitDistToTarget[0] = distToTarget / maxScoreDistance;
        fitDistFromOrigin[0] += avgPos.magnitude / maxScoreDistance;

        targetDirX[0] = targetDirection.x;
        targetDirY[0] = targetDirection.y;
        targetDirZ[0] = targetDirection.z;

        if(distToTarget < targetRadius) {
            fitTimeToTarget[0] += 0f;
        }
        else {
            fitTimeToTarget[0] += 1f;
        }

        gameTicked = true;
    }
예제 #34
0
 public void ResetMotorConfig()
 {
     JointMotor mtr = new JointMotor();
     mtr.force = force;
     mtr.targetVelocity = 0;
     mtr.freeSpin = freeSpin;
     hingeJnt.motor = mtr;
 }
예제 #35
0
 static public int get_freeSpin(IntPtr l)
 {
     UnityEngine.JointMotor o = (UnityEngine.JointMotor)checkSelf(l);
     pushValue(l, o.freeSpin);
     return(1);
 }
예제 #36
0
 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";
 }
예제 #37
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;
    }
예제 #38
0
		private extern void INTERNAL_set_motor(ref JointMotor value);
예제 #39
0
 // Use this for initialization
 void Start()
 {
     rgb=GetComponent <Rigidbody> ();
     acc = new Vector3 (0, 0, 0);
     mdl = 70;
     x = 0; y= 0;
     cuchillas = false;
     cuem=cue.motor;
     cued = cud.motor;
     chek = false;
 }