Ejemplo n.º 1
1
	void Start ()
	{
		//Get Motor Components
		armHinge = GameObject.Find ("GoblinBossArm").GetComponent<HingeJoint2D>();
		armMotor = armHinge.motor;
		
		//Set Motor Configs
		armMotor.motorSpeed = 45.0f;
		armMotor.maxMotorTorque = 20.0f;	
		armHinge.motor = armMotor;

		//Set Sight Configs
		//Initialize sight ray
		sightRay1Start = sight1Start.position;
		sightRay1End = sight1End.position;

		sightRay2Start = sight2Start.position;
		sightRay2End = sight2End.position;

		//Debug
		//Debug.Log("Motor Speed Set: "+armHinge.motor.motorSpeed);

		//Invoke TiltBack
		Invoke ("TiltArmBack", 1.5f);
		InvokeRepeating("PlayAudio", 1.0f, 10.0f);

		//hits config
		_hits = GameObject.Find ("GoblinBossBody").GetComponent<GoblinBody>();
	}
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go != null)
            {
                _joint = go.GetComponent<SliderJoint2D>();

                if(_joint!=null)
                {
                    _motor = _joint.motor;
                    _limits = _joint.limits;
                }
            }

            SetProperties();

            if(!everyFrame)
            {
                Finish();
            }
        }
Ejemplo n.º 3
0
    void Awake()
    {
        isOpened = false;
        _rigidbody = gameObject.GetComponent<Rigidbody2D>();
        _rigidbody.gravityScale = 0.0f;
        _hinge = GetComponent<HingeJoint2D>();
        JointAngleLimits2D anglelLimits = new JointAngleLimits2D();
        anglelLimits.min = initialMinAngle;
        anglelLimits.max = initalMaxAngle;
        motors = new JointMotor2D();
        motors.motorSpeed = 0;
        motors.maxMotorTorque = 10000;

        if(clockwise)
        {
            openedSpeed = _absolute_speed;
            closeSpeed = -1f * _absolute_speed;
        }
        else
        {
            openedSpeed = -1f * _absolute_speed;
            closeSpeed = _absolute_speed;
        }

        _hinge.limits = anglelLimits;
    }
Ejemplo n.º 4
0
 IEnumerator BallPickup()
 {
     HingeJoint2D hinge = GetComponent<HingeJoint2D> ();
     CircleCollider2D collider = GetComponent<CircleCollider2D> ();
     JointMotor2D m = new JointMotor2D ();
     JointAngleLimits2D limits = new JointAngleLimits2D();
     while ( hinge.jointAngle < 272 ) {
         m.motorSpeed = 350;
         m.maxMotorTorque = 1000000;
         yield return 0;
         Debug.Log(hinge.jointAngle);
     }
     hinge.useLimits = false;
     m.motorSpeed = 120;
     while (hinge.jointAngle < 390) {
         m.motorSpeed = 120;
         Debug.Log(hinge.jointAngle);
         yield return 0;
     }
     m.motorSpeed = 0;
     limits.min = 0;
     limits.max = 0;
     hinge.limits = limits;
     hinge.useLimits = true;
     hinge.motor = m;
 }
 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.JointMotor2D o;
         o = new UnityEngine.JointMotor2D();
         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
 }
Ejemplo n.º 6
0
    LocomotionComponent AttachLeg(GameObject socket)
    {
        // make WheelJoint2D on Vehicle body
        WheelJoint2D legJoint = gameObject.AddComponent<WheelJoint2D>();
        GameObject l = Instantiate(leg) as GameObject;

        l.transform.parent = transform;
        l.transform.localPosition = socket.transform.localPosition;
        legJoint.connectedBody = l.GetComponent<Rigidbody2D>();
        legJoint.connectedAnchor = l.transform.localPosition;
        legJoint.anchor = socket.transform.localPosition;
        legJoint.useMotor = true;
        JointSuspension2D sus = new JointSuspension2D();
        sus.frequency = 5;
        sus.dampingRatio = 1;
        legJoint.suspension = sus;
        JointMotor2D newMotor = new JointMotor2D();
        newMotor.motorSpeed = -300;
        newMotor.maxMotorTorque = 100;
        legJoint.motor = newMotor;

        SpinningLeg spinleg = l.GetComponent<SpinningLeg>();
        spinleg.SetRefToJoint(legJoint);
        return spinleg;
    }
Ejemplo n.º 7
0
    static public int set_maxMotorTorque(IntPtr l)
    {
        UnityEngine.JointMotor2D o = (UnityEngine.JointMotor2D)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.maxMotorTorque = v;
        setBack(l, o);
        return(0);
    }
Ejemplo n.º 8
0
 void Start()
 {
     startPoint = transform.position;
     body = GetComponent<Rigidbody2D>();
     jointMotor = new JointMotor2D();
     jointMotor.maxMotorTorque = 10000f;
     wheelJoint = GetComponent<HingeJoint2D>();
     wheelJoint.useMotor = true;
     //wheelJoint.motor = jointMotor;
 }
Ejemplo n.º 9
0
    void Start()
    {
        unitLossNitro = 0.999f / (NitroTime / 0.1f); // рахується скільки з nitrobar одиниць беде забираться за 0.1s
        curentNitroTimer = NitroTime;
        wheelJoints = gameObject.GetComponents<WheelJoint2D>();
        motorBack = wheelJoints[0].motor;
        motorBack.motorSpeed = Speed; // скорость машини

        wheelJoints[0].motor = motorBack;
        wheelJoints[1].motor = motorBack;
    }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.JointMotor2D o;
			o=new UnityEngine.JointMotor2D();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointMotor2D o;
         o=new UnityEngine.JointMotor2D();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointMotor2D o;
         o = new UnityEngine.JointMotor2D();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 13
0
    void FixedUpdate()
    {
        float acceleration = Input.GetAxis("Horizontal");
        HingeJoint2D hinge = GetComponent<HingeJoint2D> ();
        JointMotor2D m = new JointMotor2D ();

        // key up is powah * 1, key down is powah * -1, no key is powah * 0
        acceleration = Input.GetAxis("Vertical");

        // key up is powah * 1, key down is powah * -1, no key is powah * 0
        m.motorSpeed = speed * acceleration;
        hinge.useMotor = true;
    }
Ejemplo n.º 14
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointMotor2D o;
         o = new UnityEngine.JointMotor2D();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static void SliderJoint2D_motor(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.SliderJoint2D _this = (UnityEngine.SliderJoint2D)vc.csObj;
         var result = _this.motor;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.JointMotor2D  arg0  = (UnityEngine.JointMotor2D)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.SliderJoint2D _this = (UnityEngine.SliderJoint2D)vc.csObj;
         _this.motor = arg0;
     }
 }
	// Update is called once per frame
	void Update () 
    {
        if (Input.GetKey(KeyCode.RightArrow))
        {
            jointMotor = wheelJoint.motor;
            jointMotor.motorSpeed += 1f;
            wheelJoint.motor = jointMotor;
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            jointMotor = wheelJoint.motor;
            jointMotor.motorSpeed -= 1f;
            wheelJoint.motor = jointMotor;
        }
	}
Ejemplo n.º 17
0
 static void JointMotor2D_maxMotorTorque(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.JointMotor2D _this = (UnityEngine.JointMotor2D)vc.csObj;
         var result = _this.maxMotorTorque;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single            arg0  = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.JointMotor2D _this = (UnityEngine.JointMotor2D)vc.csObj;
         _this.maxMotorTorque = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Ejemplo n.º 18
0
	// Use this for initialization
	void Start () 
	{
		//Get Motor Components
		wingHinge = GameObject.Find ("ShaddowWingsPinkBack").GetComponent<HingeJoint2D>();
		wingMotor = wingHinge.motor;
		
		//Set Motor Configs
		wingMotor.motorSpeed = 50.0f;
		wingMotor.maxMotorTorque = 5000.0f;	
		wingHinge.motor = wingMotor;
		
		//Debug
		//Debug.Log("Motor Speed Set: "+wingHinge.motor.motorSpeed);
		
		//Invoke WingsDown
		Invoke ("WingsFlightDown", 1.5f);
	}
Ejemplo n.º 19
0
	void Start ()
	{
		//GetHits
		_hits = GameObject.Find("GoblinBossBody").GetComponent<GoblinBody>();

		//Get Component
		headHinge = GameObject.Find ("GoblinBossHead").GetComponent<HingeJoint2D>();
		headMotor = headHinge.motor;

		headMotor.motorSpeed = 5.0f;
		headMotor.maxMotorTorque = 20.0f;	
		headHinge.motor = headMotor;

		Debug.Log("Motor Speed Set: "+headHinge.motor.motorSpeed);

		Invoke ("TiltHeadBack", 1.5f);
	}
Ejemplo n.º 20
0
 // ugly code incoming
 void OnTriggerEnter2D(Collider2D otherCollider)
 {
     HingeJoint2D hinge = GetComponent<HingeJoint2D> ();
     CircleCollider2D collider = GetComponent<CircleCollider2D> ();
     JointMotor2D m = new JointMotor2D ();
     JointAngleLimits2D limits = new JointAngleLimits2D();
     limits.min = 270;
     limits.max = 275;
     hinge.limits = limits;
     //hinge.useLimits = false;
     m.motorSpeed = 160;
     //hinge.useLimits = false;
     m.maxMotorTorque = 1000000;
     hinge.motor = m;
     collider.isTrigger = false;
     StartCoroutine (BallPickup());
 }
Ejemplo n.º 21
0
 // Use this for initialization
 void Update()
 {
     HingeJoint2D hinge = GetComponent<HingeJoint2D> ();
     JointMotor2D m = new JointMotor2D ();
     if (Input.GetButton ("Fire1") == true) {
                     m.motorSpeed = 900;
                     m.maxMotorTorque = 100000;
                     hinge.motor = m;
             } else if (Input.GetButton ("Fire2") == true) {
                     m.motorSpeed = 900;
                     m.maxMotorTorque = 100000;
                     hinge.motor = m;
             } else {
                     m.motorSpeed = 0;
                     m.maxMotorTorque = 100000;
                     hinge.motor = m;
             }
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Read the data using the reader.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public override object Read(ISaveGameReader reader)
        {
            UnityEngine.JointMotor2D jointMotor2D = new UnityEngine.JointMotor2D();
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "motorSpeed":
                    jointMotor2D.motorSpeed = reader.ReadProperty <System.Single> ();
                    break;

                case "maxMotorTorque":
                    jointMotor2D.maxMotorTorque = reader.ReadProperty <System.Single> ();
                    break;
                }
            }
            return(jointMotor2D);
        }
Ejemplo n.º 23
0
    public void Close()
    {
        if (debug)
        {
            Debug.Log("CLOSING DOOR");
        }

        if (state != State.Closing)
        {
            JointMotor2D motor = new JointMotor2D();
            motor.motorSpeed = -doorSpeed;
            motor.maxMotorTorque = doorForce;
            doorSlider.motor = motor;
            doorSlider.useMotor = true;

            AudioSource.PlayClipAtPoint(closeClip, transform.position);
            state = State.Closing;
        }
    }
Ejemplo n.º 24
0
 // Update is called once per frame
 void Update()
 {
     if(Input.GetKey(KeyCode.H)) {
         targetangle = -5f;
         lockarm = false;
     }
     if (Input.GetKey (KeyCode.J)) {
         targetangle = 30f;
         lockarm = false;
     }
     if (Input.GetKey (KeyCode.K)) {
         targetangle = 70f;
         lockarm = false;
     }
     HingeJoint2D hinge = GetComponent<HingeJoint2D> ();
     JointMotor2D m = new JointMotor2D ();
     float jointangle = hinge.jointAngle;
     //Debug.Log("Targetangle" + targetangle.ToString() + " hinge angle:" + jointangle.ToString());
     if (targetangle < hinge.jointAngle) {
         if(!lockarm) {
             m.motorSpeed = -150*speed;
         } else {
             m.motorSpeed = -150*speed*((Mathf.Abs(targetangle-jointangle))/50);
         }
     }
     if (targetangle > hinge.jointAngle) {
         if(!lockarm) {
             m.motorSpeed = 150*speed;
         } else {
             m.motorSpeed = 150*speed*((Mathf.Abs(targetangle-jointangle))/50);
         }
     }
     m.maxMotorTorque = 10000;
     hinge.motor = m;
     hinge.useMotor = true;
     if (Mathf.Abs (targetangle - jointangle) < 3) {
         lockarm = true;
     }
 }
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go != null)
            {
                _wj2d = go.GetComponent<WheelJoint2D>();

                if(_wj2d!=null)
                {
                    _motor = _wj2d.motor;
                    _suspension = _wj2d.suspension;
                }
            }

            SetProperties();

            if(!everyFrame)
            {
                Finish();
            }
        }
Ejemplo n.º 26
0
    private void SpeedHandler(float speedValue)
    {
        if (_wheels == null || _wheels.Length < 2)
            return;

        foreach (var item in _wheels)
        {
            if (item == null)
                continue;  

            if (!item.useMotor)
                item.useMotor = true;

            var tempMotor = new JointMotor2D();
            tempMotor = item.motor;

            if (speedValue == 0)
                tempMotor.motorSpeed = 0;
            else
                tempMotor.motorSpeed += TruckConfig.EngineAcceleration * speedValue * Time.deltaTime;
            
            item.motor = tempMotor;
        }
    }
Ejemplo n.º 27
0
 private extern void set_motor_Injected(ref JointMotor2D value);
Ejemplo n.º 28
0
 private extern void get_motor_Injected(out JointMotor2D ret);
Ejemplo n.º 29
0
 // Use this for initialization
 void Start()
 {
     motor = joint.motor;
 }
Ejemplo n.º 30
0
 // Use this for initialization
 void Start()
 {
     motor = this.GetComponent<WheelJoint2D>().motor;
 }
Ejemplo n.º 31
0
    // Use this for initialization
    void Start()
    {
        hinge = GetComponent<HingeJoint2D>();
        motor = hinge.motor;
		jointAngle = hinge.jointAngle;
    }
Ejemplo n.º 32
0
		private extern void INTERNAL_get_motor(out JointMotor2D value);
Ejemplo n.º 33
0
 private extern void INTERNAL_get_motor(out JointMotor2D value);
Ejemplo n.º 34
0
 static public int get_maxMotorTorque(IntPtr l)
 {
     UnityEngine.JointMotor2D o = (UnityEngine.JointMotor2D)checkSelf(l);
     pushValue(l, o.maxMotorTorque);
     return(1);
 }
 // Use this for initialization
 void Start()
 {
     joint = GetComponent<WheelJoint2D>();
     motor = new JointMotor2D();
     motor.maxMotorTorque = 10000;
 }
Ejemplo n.º 36
0
    void Start()
    {
        curentNitroTimer = NitroTime;
        rigidbody2D = GetComponent<Rigidbody2D>();
        wheelJoints = GetComponents<WheelJoint2D>();
        motorBack = wheelJoints[0].motor;
        motorBack.motorSpeed = Speed; // скорость машини

        wheelJoints[0].motor = motorBack;
        wheelJoints[1].motor = motorBack;
    }
Ejemplo n.º 37
0
 void Start()
 {
     joint = transform.Find("biker_arm_1").GetComponent<HingeJoint2D>();
     motor = new JointMotor2D();
     motor.maxMotorTorque = 1000;
     ColliderDetector[] detectors = GetComponentsInChildren<ColliderDetector>();
     foreach(ColliderDetector detector in detectors)
     {
         detector.TriggerEnter += onTriggerEnter;
     }
 }
Ejemplo n.º 38
0
 private extern void INTERNAL_set_motor(ref JointMotor2D value);
Ejemplo n.º 39
0
 static public int get_motorSpeed(IntPtr l)
 {
     UnityEngine.JointMotor2D o = (UnityEngine.JointMotor2D)checkSelf(l);
     pushValue(l, o.motorSpeed);
     return(1);
 }
Ejemplo n.º 40
0
		private extern void INTERNAL_set_motor(ref JointMotor2D value);
Ejemplo n.º 41
0
 // Use this for initialization
 void Start()
 {
     joint.connectedAnchor = transform.position;
     motor = joint.motor;
 }
Ejemplo n.º 42
0
    // Use this for initialization
    void Start()
    {
        //set the center of mass of the car
        //Vector3 center = GetComponent<Rigidbody2D>().centerOfMass;
        //center.y -= 1;
        //GetComponent<Rigidbody2D>().centerOfMass = center;

        //get the wheeljoint components
        wheelJoints = gameObject.GetComponents<WheelJoint2D>();
        //get the reference to the motor of rear wheels joint
        motorBack = wheelJoints[0].motor;
        motorFront = wheelJoints[1].motor;
    }
Ejemplo n.º 43
0
    void loadJsonJoints(JSONNode jsonJoints)
    {
        int JointCount = 0;

        for (int i = 0, numberOfJoints = jsonJoints.Count; i < numberOfJoints; i++){
            JSONNode jsonJoint = jsonJoints[i];
            int jointType = jsonJoint["jointType"].AsInt;

            GameObject bodyA = loadedObjects[jsonJoint["bodyA"].AsInt];
            GameObject bodyB = loadedObjects[jsonJoint["bodyB"].AsInt];

            JSONNode localAnchorA = jsonJoint["localAnchorA"];
            Vector2 anchorA = new Vector2(localAnchorA[0].AsFloat / RATIO, -localAnchorA[1].AsFloat / RATIO);
            JSONNode localAnchorB = jsonJoint["localAnchorB"];
            Vector2 anchorB = new Vector2(localAnchorB[0].AsFloat / RATIO, -localAnchorB[1].AsFloat / RATIO);
            bool collideConnected = jsonJoint["collideConnected"].AsBool;
            string userData = jsonJoint["userData"].Value;

            if (jointType == (int) JointTypes.JOINT_DISTANCE || jointType == (int) JointTypes.JOINT_ROPE){
                DistanceJoint2D joint = bodyA.AddComponent<DistanceJoint2D>();
                joint.connectedBody = bodyB.GetComponent<Rigidbody2D>();
                joint.anchor = anchorA;
                joint.connectedAnchor = anchorB;

                // distance joint
                if (jsonJoint["length"] != null){
                    joint.distance = jsonJoint["length"].AsFloat / RATIO;
                    joint.maxDistanceOnly = true;
                }
                // rope joint
                else if (jsonJoint["maxLength"] != null){
                    joint.distance = jsonJoint["maxLength"].AsFloat / RATIO;
                }

                joint.enableCollision = collideConnected;
                joint.name += '_';
                joint.name += userData.Length > 0 ? userData : "joint" + JointCount++;
            }
            else if (jointType == (int) JointTypes.JOINT_REVOLUTE){
                HingeJoint2D joint = bodyA.AddComponent<HingeJoint2D>();
                joint.connectedBody = bodyB.GetComponent<Rigidbody2D>();
                joint.anchor = anchorA;
                joint.connectedAnchor = anchorB;
                joint.enableCollision = collideConnected;
                joint.name += '_';
                joint.name += userData.Length > 0 ? userData : "joint" + JointCount++;

                // limits are not working properly
                bool enableLimits = jsonJoint["enableLimit"].AsBool;
                float referenceAngle = -jsonJoint["referenceAngle"].AsFloat;
                float angleBetweenBodies = Mathf.Atan2(bodyB.transform.position.y - bodyA.transform.position.y,
                                                      bodyB.transform.position.x - bodyA.transform.position.x) * 180 / Mathf.PI;
                float upperAngle = -jsonJoint["lowerAngle"].AsFloat;
                float lowerAngle = -jsonJoint["upperAngle"].AsFloat;
                bool enableMotor = jsonJoint["enableMotor"].AsBool;
                float motorSpeed = -jsonJoint["motorSpeed"].AsFloat;
                float maxMotorTorque = jsonJoint["maxMotorTorque"].AsFloat;

                joint.useLimits = enableLimits;
                JointAngleLimits2D limits = new JointAngleLimits2D();
                limits.max = angleBetweenBodies + upperAngle;
                limits.min = angleBetweenBodies + lowerAngle;
                joint.limits = limits;
                joint.useMotor = enableMotor;
                JointMotor2D motor = new JointMotor2D();
                motor.maxMotorTorque = maxMotorTorque;
                motor.motorSpeed = motorSpeed;
                joint.motor = motor;
            }
            else if (jointType == (int) JointTypes.JOINT_WHEEL){
                WheelJoint2D joint = bodyA.AddComponent<WheelJoint2D>();
                joint.connectedBody = bodyB.GetComponent<Rigidbody2D>();
                joint.anchor = anchorA;
                joint.connectedAnchor = anchorB;
                joint.enableCollision = collideConnected;
                joint.name += '_';
                joint.name += userData.Length > 0 ? userData : "joint" + JointCount++;

                bool enableMotor = jsonJoint["enableMotor"].AsBool;
                float motorSpeed = -jsonJoint["motorSpeed"].AsFloat;
                float maxMotorTorque = jsonJoint["maxMotorTorque"].AsFloat;
                float dampingRatio = jsonJoint["dampingRatio"].AsFloat;
                float frequency = jsonJoint["frequencyHZ"].AsFloat;
                JSONNode localAxisA = jsonJoint["localAxisA"];
                float angle = Mathf.Atan2(-localAxisA[1].AsFloat, localAxisA[0].AsFloat) * 180 / Mathf.PI;

                joint.useMotor = enableMotor;
                JointMotor2D motor = new JointMotor2D();
                motor.maxMotorTorque = maxMotorTorque;
                motor.motorSpeed = motorSpeed;
                joint.motor = motor;

                JointSuspension2D suspension = new JointSuspension2D();
                suspension.dampingRatio = dampingRatio;
                suspension.frequency = frequency;
                suspension.angle = angle;
                joint.suspension = suspension;
            }
            else if (jointType == (int) JointTypes.JOINT_PRISMATIC){
                SliderJoint2D joint = bodyA.AddComponent<SliderJoint2D>();
                joint.connectedBody = bodyB.GetComponent<Rigidbody2D>();
                joint.anchor = anchorA;
                joint.connectedAnchor = anchorB;
                joint.enableCollision = collideConnected;
                joint.name += '_';
                joint.name += userData.Length > 0 ? userData : "joint" + JointCount++;

                bool enableLimits = jsonJoint["enableLimit"].AsBool;
                float referenceAngle = -jsonJoint["referenceAngle"].AsFloat;
                float upperTranslation = jsonJoint["upperTranslation"].AsFloat / RATIO;
                float lowerTranslation = jsonJoint["lowerTranslation"].AsFloat / RATIO;
                bool enableMotor = jsonJoint["enableMotor"].AsBool;
                float motorSpeed = -jsonJoint["motorSpeed"].AsFloat;
                float maxMotorTorque = jsonJoint["maxMotorTorque"].AsFloat;
                JSONNode localAxisA = jsonJoint["localAxisA"];
                float angle = Mathf.Atan2(-localAxisA[1].AsFloat, localAxisA[0].AsFloat) * 180 / Mathf.PI;

                joint.useLimits = enableLimits;
                JointTranslationLimits2D limits = new JointTranslationLimits2D();
                limits.max = upperTranslation;
                limits.min = lowerTranslation;
                joint.limits = limits;
                joint.useMotor = enableMotor;
                JointMotor2D motor = new JointMotor2D();
                motor.maxMotorTorque = maxMotorTorque;
                motor.motorSpeed = motorSpeed;
                joint.motor = motor;
                joint.angle = angle;
            }
        }
    }
Ejemplo n.º 44
0
 private void INTERNAL_set_motor(ref JointMotor2D value)
 {
     throw new NotImplementedException("なにこれ");
 }
Ejemplo n.º 45
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.JointMotor2D jointMotor2D = (UnityEngine.JointMotor2D)value;
     writer.WriteProperty("motorSpeed", jointMotor2D.motorSpeed);
     writer.WriteProperty("maxMotorTorque", jointMotor2D.maxMotorTorque);
 }