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.JointAngleLimits2D o;
         o = new UnityEngine.JointAngleLimits2D();
         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.º 2
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;
 }
Ejemplo n.º 3
0
 private void DropBridge()
 {
     JointAngleLimits2D newLimits = new JointAngleLimits2D();
     newLimits.min = 0;
     newLimits.max = mHinge.limits.max;
     mHinge.limits = newLimits;
 }
Ejemplo n.º 4
0
    void EnableRagdollBodyParts( bool enable )
    {
        HingeJoint2D joint = GetComponent<HingeJoint2D> ();
        Rigidbody2D rigid = GetComponent<Rigidbody2D> ();

        if (enable && !rigid && !joint) {
            transform.gameObject.AddComponent<Rigidbody2D>();
            HingeJoint2D newJoint = transform.gameObject.AddComponent<HingeJoint2D>();
            newJoint.anchor = savedAnchor;
            newJoint.connectedAnchor = savedConnectedAnchor;
            newJoint.connectedBody = savedConnectedGameObject.GetComponent<Rigidbody2D>();
            newJoint.useLimits = savedUseJointLimits;
            newJoint.limits = savedJointLimits;
        ;
        } else if( !enable && rigid && joint ) {
            savedAnchor = joint.anchor;
            savedConnectedAnchor = joint.connectedAnchor;
            savedConnectedGameObject = joint.connectedBody.gameObject;
            savedUseJointLimits = joint.useLimits;
            savedJointLimits = joint.limits;

            Destroy( joint );
            Destroy( rigid );

        }
    }
Ejemplo n.º 5
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;
    }
    static public int set_max(IntPtr l)
    {
        UnityEngine.JointAngleLimits2D o = (UnityEngine.JointAngleLimits2D)checkSelf(l);
        float v;

        checkType(l, 2, out v);
        o.max = v;
        setBack(l, o);
        return(0);
    }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.JointAngleLimits2D o;
			o=new UnityEngine.JointAngleLimits2D();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointAngleLimits2D o;
         o=new UnityEngine.JointAngleLimits2D();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointAngleLimits2D o;
         o = new UnityEngine.JointAngleLimits2D();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.JointAngleLimits2D o;
         o = new UnityEngine.JointAngleLimits2D();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static void HingeJoint2D_limits(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.HingeJoint2D _this = (UnityEngine.HingeJoint2D)vc.csObj;
         var result = _this.limits;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.JointAngleLimits2D arg0  = (UnityEngine.JointAngleLimits2D)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.HingeJoint2D       _this = (UnityEngine.HingeJoint2D)vc.csObj;
         _this.limits = arg0;
     }
 }
Ejemplo n.º 12
0
 // Use this for initialization
 void Start()
 {
     _hinge = GetComponent<HingeJoint2D>();
     _jointmotors.motorSpeed = releaseSpeed;
     _jointmotors.maxMotorTorque = 10000.0f;
     _hinge.motor = _jointmotors;
     _hinge.useMotor = true;
     _hinge.useLimits = true;
     JointAngleLimits2D jl = new JointAngleLimits2D();
     jl.min = minAngle;
     jl.max = maxAngle;
     _hinge.limits = jl;
     _movingUp = true;
     _trigger = true;
 }
Ejemplo n.º 13
0
 static void JointAngleLimits2D_max(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.JointAngleLimits2D _this = (UnityEngine.JointAngleLimits2D)vc.csObj;
         var result = _this.max;
         JSApi.setSingle((int)JSApi.SetType.Rval, (System.Single)(result));
     }
     else
     {
         System.Single arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
         UnityEngine.JointAngleLimits2D _this = (UnityEngine.JointAngleLimits2D)vc.csObj;
         _this.max = arg0;
         JSMgr.changeJSObj(vc.jsObjID, _this);
     }
 }
Ejemplo n.º 14
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());
 }
        /// <summary>
        /// Read the data using the reader.
        /// </summary>
        /// <param name="reader">Reader.</param>
        public override object Read(ISaveGameReader reader)
        {
            UnityEngine.JointAngleLimits2D jointAngleLimits2D = new UnityEngine.JointAngleLimits2D();
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "min":
                    jointAngleLimits2D.min = reader.ReadProperty <System.Single> ();
                    break;

                case "max":
                    jointAngleLimits2D.max = reader.ReadProperty <System.Single> ();
                    break;
                }
            }
            return(jointAngleLimits2D);
        }
Ejemplo n.º 16
0
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

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

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

            SetProperties();

            if(!everyFrame)
            {
                Finish();
            }
        }
Ejemplo n.º 17
0
    // Use this for initialization
    void Awake()
    {
        health = maxHealth;

        GameObject last = null;
        Vector3 point = Vector3.zero;

        var limits = new JointAngleLimits2D();
        limits.max = 40;
        limits.min = -40;

        float biggestR = 0;

        for (int i = 0; i < dragonCurve[dragonCurve.length - 1].time; i++)
        {
            float r = dragonCurve.Evaluate(i);
            point.x += r;
            point.z -= 0.1f;
            GameObject next = new GameObject(name + " " + i, typeof(Rigidbody2D), typeof(CircleCollider2D), typeof(DragonPiece));
            if (!tail)
                tail = next.rigidbody2D;

            next.transform.parent = transform;

            next.GetComponent<CircleCollider2D>().radius = r;
            next.transform.position = transform.TransformPoint(point);
            next.transform.rotation = transform.rotation;
            next.rigidbody2D.mass = Mathf.PI * r * r;
            next.rigidbody2D.drag = 3;
            next.rigidbody2D.angularDrag = 1;
            next.rigidbody2D.gravityScale = 1;

            next.layer = gameObject.layer;

            var g = new GameObject("gfx", typeof(SpriteRenderer));
            g.GetComponent<SpriteRenderer>().sprite = piece;
            g.transform.parent = next.transform;
            g.transform.localScale = Vector3.one * r * 2;
            g.transform.localPosition = Vector3.zero;
            g.transform.localRotation = Quaternion.identity;

            var blood = Instantiate(bloodParticles, next.transform.position, next.transform.rotation) as ParticleSystem;
            blood.transform.parent = next.transform;

            point.x += r;

            if (r > biggestR)
            {
                biggestR = r;
                biggest = next.rigidbody2D;
            }

            if (last)
            {
                var joint = next.AddComponent<HingeJoint2D>();
                joint.connectedBody = last.rigidbody2D;
                joint.connectedAnchor = new Vector2(next.GetComponent<CircleCollider2D>().radius + last.GetComponent<CircleCollider2D>().radius, 0);
                joint.collideConnected = false;
                joint.useLimits = true;
                joint.limits = limits;
                last.GetComponent<DragonPiece>().front = next.transform;
            }
            last = next;
        }
        headGfxTransform = last.transform.Find("gfx");
        headGfxTransform.GetComponent<SpriteRenderer>().sprite = headGfx;

        biteFx = Instantiate(biteFx, last.transform.position + new Vector3(0, 0, -1), Quaternion.identity) as ParticleSystem;
        biteFx.transform.parent = last.transform;
        biteFx.enableEmission = false;
        biteCharged = Instantiate(biteCharged, last.transform.position + new Vector3(0, 0, -1), Quaternion.identity) as ParticleSystem;
        biteCharged.transform.parent = last.transform;
        biteCharged.enableEmission = false;

        head = last.rigidbody2D;
    }
 static public int get_max(IntPtr l)
 {
     UnityEngine.JointAngleLimits2D o = (UnityEngine.JointAngleLimits2D)checkSelf(l);
     pushValue(l, o.max);
     return(1);
 }
Ejemplo n.º 19
0
 private extern void INTERNAL_set_limits(ref JointAngleLimits2D value);
Ejemplo n.º 20
0
 private extern void INTERNAL_get_limits(out JointAngleLimits2D value);
Ejemplo n.º 21
0
 private void INTERNAL_set_limits(ref JointAngleLimits2D value)
 {
     throw new NotImplementedException("なにこれ");
 }
Ejemplo n.º 22
0
 private extern void set_limits_Injected(ref JointAngleLimits2D value);
Ejemplo n.º 23
0
 private extern void INTERNAL_get_limits(out JointAngleLimits2D value);
Ejemplo n.º 24
0
	void OnGUI()
	{
		GUILayout.Space(10);

		if(root)
			rootTempName = root.name;

		root = (Transform)EditorGUILayout.ObjectField ("Root", root, typeof(Transform), true);
		if(root && root.name != rootTempName)
		{
			jointPositionsCreated = false;

			//clear body parts
			body = null;
			head = null;
			neck = null;
			spine = null;
			upperArm1 = null;
			upperArm2 = null;
			lowerArm1 = null;
			lowerArm2 = null;
			wrist1 = null;
			wrist2 = null;
			thigh1 = null;
			thigh2 = null;
			leg1 = null;
			leg2 = null;
			foot1 = null;
			foot2 = null;
		}

		//create object assignment fields for body parts
		//create check box to controll use or not use angle limits on body parts
		//create text fields for body part's lower and upper angles and make imposible to enter 0 there

		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		body = (GameObject)EditorGUILayout.ObjectField ("Body", body, typeof(GameObject), true);
		GUILayout.Space(20);
		GUILayout.Label ("Use Limits");
		GUILayout.Label ("Lower Angle");
		GUILayout.Label ("Upper Angle");
		GUILayout.EndHorizontal ();

		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		head = (GameObject)EditorGUILayout.ObjectField ("Head", head, typeof(GameObject), true);
		GUILayout.Space (10);
		headUseLimit = GUILayout.Toggle(headUseLimit,"");
		headLowerAngle = GUILayout.TextField (headLowerAngle,4);
		headLowerAngle = Regex.Replace(headLowerAngle, @"[^0-9-]", "");
		if(headLowerAngle == "") 
			headLowerAngle = "0";
		headUpperAngle = GUILayout.TextField (headUpperAngle,4);
		headUpperAngle = Regex.Replace(headUpperAngle, @"[^0-9-]", "");
		if(headUpperAngle == "")
			headUpperAngle = "0";
		GUILayout.EndHorizontal ();

		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		neck = (GameObject)EditorGUILayout.ObjectField ("Neck", neck, typeof(GameObject), true);
		GUILayout.Space (10);
		neckUseLimit = GUILayout.Toggle(neckUseLimit,"");
		neckLowerAngle = GUILayout.TextField (neckLowerAngle,4);
		neckLowerAngle = Regex.Replace(neckLowerAngle, @"[^0-9-]", "");
		if(neckLowerAngle == "") 
			neckLowerAngle = "0";
		neckUpperAngle = GUILayout.TextField (neckUpperAngle,4);
		neckUpperAngle = Regex.Replace(neckUpperAngle, @"[^0-9-]", "");
		if(neckUpperAngle == "")
			neckUpperAngle = "0";
		GUILayout.EndHorizontal ();
		
		GUILayout.Space(5);
		
		GUILayout.BeginHorizontal ();
		spine = (GameObject)EditorGUILayout.ObjectField ("Spine", spine, typeof(GameObject), true);
		GUILayout.Space (10);
		spineUseLimit = GUILayout.Toggle(spineUseLimit,"");
		spineLowerAngle = GUILayout.TextField (spineLowerAngle,4);
		spineLowerAngle = Regex.Replace(spineLowerAngle, @"[^0-9-]", "");
		if(spineLowerAngle == "") 
			spineLowerAngle = "0";
		spineUpperAngle = GUILayout.TextField (spineUpperAngle,4);
		spineUpperAngle = Regex.Replace(spineUpperAngle, @"[^0-9-]", "");
		if(spineUpperAngle == "")
			spineUpperAngle = "0";
		GUILayout.EndHorizontal ();
		
		GUILayout.Space(5);
		
		GUILayout.BeginHorizontal();
		upperArm1 = (GameObject)EditorGUILayout.ObjectField ("Upper Arm 1", upperArm1, typeof(GameObject), true);
		GUILayout.Space (10);
		upperArm1UseLimit = GUILayout.Toggle(upperArm1UseLimit,"");
		upperArm1LowerAngle = GUILayout.TextField (upperArm1LowerAngle,4);
		upperArm1LowerAngle = Regex.Replace (upperArm1LowerAngle, @"[^0-9-]", "");
		if(upperArm1LowerAngle == "") 
			upperArm1LowerAngle = "0";
		upperArm1UpperAngle = GUILayout.TextField (upperArm1UpperAngle,4);
		upperArm1UpperAngle = Regex.Replace (upperArm1UpperAngle, @"[^0-9-]", "");
		if(upperArm1UpperAngle == "") 
			upperArm1UpperAngle = "0";
		GUILayout.EndHorizontal ();

		GUILayout.Space(5);

		GUILayout.BeginHorizontal();
		upperArm2 = (GameObject)EditorGUILayout.ObjectField ("Upper Arm 2", upperArm2, typeof(GameObject), true);
		GUILayout.Space (10);
		upperArm2UseLimit = GUILayout.Toggle(upperArm2UseLimit,"");
		upperArm2LowerAngle = GUILayout.TextField (upperArm2LowerAngle,4);
		upperArm2LowerAngle = Regex.Replace (upperArm2LowerAngle, @"[^0-9-]", "");
		if(upperArm2LowerAngle == "") 
			upperArm2LowerAngle = "0";
		upperArm2UpperAngle = GUILayout.TextField (upperArm2UpperAngle,4);
		upperArm2UpperAngle = Regex.Replace (upperArm2UpperAngle, @"[^0-9-]", "");
		if(upperArm2UpperAngle == "") 
			upperArm2UpperAngle = "0";
		GUILayout.EndHorizontal ();
		
		GUILayout.Space(5);

		GUILayout.BeginHorizontal();
		lowerArm1 = (GameObject)EditorGUILayout.ObjectField ("Lower Arm 1", lowerArm1, typeof(GameObject), true);
		GUILayout.Space (10);
		lowerArm1UseLimit = GUILayout.Toggle(lowerArm1UseLimit,"");
		lowerArm1LowerAngle = GUILayout.TextField (lowerArm1LowerAngle,4);
		lowerArm1LowerAngle = Regex.Replace(lowerArm1LowerAngle, @"[^0-9-]", "");
		if(lowerArm1LowerAngle == "") 
			lowerArm1LowerAngle = "0";
		lowerArm1UpperAngle = GUILayout.TextField (lowerArm1UpperAngle,4);
		lowerArm1UpperAngle = Regex.Replace(lowerArm1UpperAngle, @"[^0-9-]", "");
		if(lowerArm1UpperAngle == "") 
			lowerArm1UpperAngle = "0";
		GUILayout.EndHorizontal();
		
		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		lowerArm2 = (GameObject)EditorGUILayout.ObjectField ("Lower Arm 2", lowerArm2, typeof(GameObject), true);
		GUILayout.Space (10);
		lowerArm2UseLimit = GUILayout.Toggle(lowerArm2UseLimit,"");
		lowerArm2LowerAngle = GUILayout.TextField (lowerArm2LowerAngle,4);
		lowerArm2LowerAngle = Regex.Replace(lowerArm2LowerAngle, @"[^0-9-]", "");
		if(lowerArm2LowerAngle == "") 
			lowerArm2LowerAngle = "0";
		lowerArm2UpperAngle = GUILayout.TextField (lowerArm2UpperAngle,4);
		lowerArm2UpperAngle = Regex.Replace(lowerArm2UpperAngle, @"[^0-9-]", "");
		if(lowerArm2UpperAngle == "") 
			lowerArm2UpperAngle = "0";
		GUILayout.EndHorizontal();

		GUILayout.Space(5);
		
		GUILayout.BeginHorizontal ();
		wrist1 = (GameObject)EditorGUILayout.ObjectField ("Wrist 1", wrist1, typeof(GameObject), true);
		GUILayout.Space (10);
		wrist1UseLimit = GUILayout.Toggle(wrist1UseLimit,"");
		wrist1LowerAngle = GUILayout.TextField (wrist1LowerAngle,4);
		wrist1LowerAngle = Regex.Replace(wrist1LowerAngle, @"[^0-9-]", "");
		if(wrist1LowerAngle == "") 
			wrist1LowerAngle = "0";
		wrist1UpperAngle = GUILayout.TextField (wrist1UpperAngle,4);
		wrist1UpperAngle = Regex.Replace(wrist1UpperAngle, @"[^0-9-]", "");
		if(wrist1UpperAngle == "") 
			wrist1UpperAngle = "0";
		GUILayout.EndHorizontal();
		
		GUILayout.Space(5);
		
		GUILayout.BeginHorizontal ();
		wrist2 = (GameObject)EditorGUILayout.ObjectField ("Wrist 2", wrist2, typeof(GameObject), true);
		GUILayout.Space (10);
		wrist2UseLimit = GUILayout.Toggle(wrist2UseLimit,"");
		wrist2LowerAngle = GUILayout.TextField (wrist2LowerAngle,4);
		wrist2LowerAngle = Regex.Replace(wrist2LowerAngle, @"[^0-9-]", "");
		if(wrist2LowerAngle == "") 
			wrist2LowerAngle = "0";
		wrist2UpperAngle = GUILayout.TextField (wrist2UpperAngle,4);
		wrist2UpperAngle = Regex.Replace(wrist2UpperAngle, @"[^0-9-]", "");
		if(wrist2UpperAngle == "") 
			wrist2UpperAngle = "0";
		GUILayout.EndHorizontal();
		
		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		thigh1 = (GameObject)EditorGUILayout.ObjectField ("Thigh 1", thigh1, typeof(GameObject), true);
		GUILayout.Space (10);
		thigh1UseLimit = GUILayout.Toggle(thigh1UseLimit,"");
		thigh1LowerAngle = GUILayout.TextField (thigh1LowerAngle,4);
		thigh1LowerAngle = Regex.Replace(thigh1LowerAngle, @"[^0-9-]", "");
		if(thigh1LowerAngle == "") 
			thigh1LowerAngle = "0";
		thigh1UpperAngle = GUILayout.TextField (thigh1UpperAngle,4);
		thigh1UpperAngle = Regex.Replace(thigh1UpperAngle, @"[^0-9-]", "");
		if(thigh1UpperAngle == "") 
			thigh1UpperAngle = "0";
		GUILayout.EndHorizontal();
		
		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		thigh2 = (GameObject)EditorGUILayout.ObjectField ("Thigh 2", thigh2, typeof(GameObject), true);
		GUILayout.Space (10);
		thigh2UseLimit = GUILayout.Toggle(thigh2UseLimit,"");
		thigh2LowerAngle = GUILayout.TextField (thigh2LowerAngle,4);
		thigh2LowerAngle = Regex.Replace(thigh2LowerAngle, @"[^0-9-]", "");
		if(thigh2LowerAngle == "") 
			thigh2LowerAngle = "0";
		thigh2UpperAngle = GUILayout.TextField (thigh2UpperAngle,4);
		thigh2UpperAngle = Regex.Replace(thigh2UpperAngle, @"[^0-9-]", "");
		if(thigh2UpperAngle == "") 
			thigh2UpperAngle = "0";
		GUILayout.EndHorizontal();

		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		leg1 = (GameObject)EditorGUILayout.ObjectField ("Leg 1", leg1, typeof(GameObject), true);
		GUILayout.Space (10);
		leg1UseLimit = GUILayout.Toggle(leg1UseLimit,"");
		leg1LowerAngle = GUILayout.TextField (leg1LowerAngle,4);
		leg1LowerAngle = Regex.Replace(leg1LowerAngle, @"[^0-9-]", "");
		if(leg1LowerAngle == "") 
			leg1LowerAngle = "0";
		leg1UpperAngle = GUILayout.TextField (leg1UpperAngle,4);
		leg1UpperAngle = Regex.Replace(leg1UpperAngle, @"[^0-9-]", "");
		if(leg1UpperAngle == "") 
			leg1UpperAngle = "0";
		GUILayout.EndHorizontal();

		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		leg2 = (GameObject)EditorGUILayout.ObjectField ("Leg 2", leg2, typeof(GameObject), true);
		GUILayout.Space (10);
		leg2UseLimit = GUILayout.Toggle(leg2UseLimit,"");
		leg2LowerAngle = GUILayout.TextField (leg2LowerAngle,4);
		leg2LowerAngle = Regex.Replace(leg2LowerAngle, @"[^0-9-]", "");
		if(leg2LowerAngle == "") 
			leg2LowerAngle = "0";
		leg2UpperAngle = GUILayout.TextField (leg2UpperAngle,4);
		leg2UpperAngle = Regex.Replace(leg2UpperAngle, @"[^0-9-]", "");
		if(leg2UpperAngle == "") 
			leg2UpperAngle = "0";
		GUILayout.EndHorizontal();

		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		foot1 = (GameObject)EditorGUILayout.ObjectField ("Foot 1", foot1, typeof(GameObject), true);
		GUILayout.Space (10);
		foot1UseLimit = GUILayout.Toggle(foot1UseLimit,"");
		foot1LowerAngle = GUILayout.TextField (foot1LowerAngle,4);
		foot1LowerAngle = Regex.Replace(foot1LowerAngle, @"[^0-9-]", "");
		if(foot1LowerAngle == "") 
			foot1LowerAngle = "0";
		foot1UpperAngle = GUILayout.TextField (foot1UpperAngle,4);
		foot1UpperAngle = Regex.Replace(foot1UpperAngle, @"[^0-9-]", "");
		if(foot1UpperAngle == "") 
			foot1UpperAngle = "0";
		GUILayout.EndHorizontal();

		GUILayout.Space(5);

		GUILayout.BeginHorizontal ();
		foot2 = (GameObject)EditorGUILayout.ObjectField ("Foot 2", foot2, typeof(GameObject), true);
		GUILayout.Space (10);
		foot2UseLimit = GUILayout.Toggle(foot2UseLimit,"");
		foot2LowerAngle = GUILayout.TextField (foot2LowerAngle,4);
		foot2LowerAngle = Regex.Replace(foot2LowerAngle, @"[^0-9-]", "");
		if(foot2LowerAngle == "") 
			foot2LowerAngle = "0";
		foot2UpperAngle = GUILayout.TextField (foot2UpperAngle,4);
		foot2UpperAngle = Regex.Replace(foot2UpperAngle, @"[^0-9-]", "");
		if(foot2UpperAngle == "") 
			foot2UpperAngle = "0";
		GUILayout.EndHorizontal();

		GUILayout.Space(5);

		//create help label, which'll give help messages
		GUIStyle guiStyle = new GUIStyle();
		guiStyle.normal.textColor = Color.green;
		guiStyle.fontSize = 14;
		guiStyle.alignment = TextAnchor.MiddleCenter;
		EditorGUILayout.LabelField (helpText, guiStyle, GUILayout.Height (50), GUILayout.MinHeight(10), GUILayout.MinHeight (20), GUILayout.MaxHeight (50)); 

		GUILayout.Space(5);


		//create auto assign button
		//when this is clicked it checks if root object is assigned, if yes it goes to its children and checks their names and assigns to appropriate body part field and saves them in variables 
		//if this object is already ragdoll, it gets and saves joint position objects, fills bodyParts and jointPositions arrays, 
		//sets lower and upper angles for body part field and saves them in varibales too
		if(GUILayout.Button ("Auto Assign", GUILayout.ExpandHeight(true), GUILayout.MinHeight (30), GUILayout.MaxHeight(50)))
		{
			if(root)
			{
				jointPositions = new List<Transform>();
				bodyParts = new List<Transform>();

				var allParts = root.GetComponentsInChildren<Transform>();
				
				foreach(var child in allParts)
				{
					if(child.name == "Joint Position")
					{
						jointPositions.Add(child);

						var parentName = child.parent.name;

						if(parentName == "head" || parentName == "spine" || parentName == "neck" || parentName == "upper arm 1" || parentName == "upper arm 2" || parentName == "lower arm 1" || 
						   parentName == "lower arm 2" ||  parentName == "wrist 1" || parentName == "wrist 2" || parentName == "thigh 1" || 
						   parentName == "thigh 2" || parentName == "leg 1" ||
						   parentName == "leg 2" || parentName == "foot 1" || parentName == "foot 2")
									bodyParts.Add(child.parent);


						if(parentName == "head")
						{
							headJointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								headLowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								headUpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "neck")
						{
							neckJointPosition = child;
							
							if(child.GetComponent<Rigidbody2D>())
							{
								neckLowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								neckUpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "spine")
						{
							spineJointPosition = child;
							
							if(child.GetComponent<Rigidbody2D>())
							{
								spineLowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								spineUpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "upper arm 1")
						{
							upperArm1JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								upperArm1LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								upperArm1UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "upper arm 2")
						{
							upperArm2JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								upperArm2LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								upperArm2UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "lower arm 1")
						{
							lowerArm1JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								lowerArm1LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								lowerArm1UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "lower arm 2")
						{
							lowerArm2JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								lowerArm2LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								lowerArm2UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "wrist 1")
						{
							wrist1JointPosition = child;
							
							if(child.GetComponent<Rigidbody2D>())
							{
								wrist1LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								wrist1UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "wrist 2")
						{
							wrist2JointPosition = child;
							
							if(child.GetComponent<Rigidbody2D>())
							{
								wrist2LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								wrist2UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "thigh 1")
						{
							thigh1JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								thigh1LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								thigh1UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "thigh 2")
						{
							thigh2JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								thigh2LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								thigh2UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "leg 1")
						{
							leg1JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								leg1LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								leg1UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "leg 2")
						{
							leg2JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								leg2LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								leg2UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "foot 1")
						{
							foot1JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								foot1LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								foot1UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}

						if(parentName == "foot 2")
						{
							foot2JointPosition = child;

							if(child.GetComponent<Rigidbody2D>())
							{
								foot2LowerAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.min;
								foot2UpperAngle = "" + child.parent.GetComponent<HingeJoint2D>().limits.max;
							}
						}


						if(jointPositions.Count == 1)
						{
							jointPositionsCreated = true;

							if(child.GetComponent<Renderer>().enabled)
						   		showJointPositions = true;
						   	else
						   		showJointPositions = false;
						}
					}

					else if(child.name == "head")
						head = child.gameObject;

					else if(child.name == "neck")
						neck = child.gameObject;

					else if(child.name == "spine")
						spine = child.gameObject;

					else if(child.name == "body")
						body = child.gameObject;
					
					else if(child.name == "upper arm 1")
						upperArm1 = child.gameObject;
					
					else if(child.name == "upper arm 2")
						upperArm2 = child.gameObject;
					
					else if(child.name == "lower arm 1")
						lowerArm1 = child.gameObject;
					
					else if(child.name == "wrist 1")
						wrist1 = child.gameObject;
					
					else if(child.name == "wrist 2")
						wrist2 = child.gameObject;

					else if(child.name == "lower arm 2")
						lowerArm2 = child.gameObject;
					
					else if(child.name == "thigh 1")
						thigh1 = child.gameObject;
					
					else if(child.name == "thigh 2")
						thigh2 = child.gameObject;
					
					else if(child.name == "leg 1")
						leg1 = child.gameObject;
					
					else if(child.name == "leg 2")
						leg2 = child.gameObject;
					
					else if(child.name == "foot 1")
						foot1 = child.gameObject;
					
					else if(child.name == "foot 2")
						foot2 = child.gameObject;
				}
				helpText = "BODY PARTS ARE ASSIGNED";
		}
		else helpText = "ROOT OBJECT ISN'T ASSIGNED";
		}

		GUILayout.Space (5);


		//create joint position objects and fill "bodyParts" and "jointPositions" arrays
		if(GUILayout.Button ((!jointPositionsCreated? "Create" : "Delete") +" Joint Positions", GUILayout.ExpandHeight(true), GUILayout.MinHeight (30), GUILayout.MaxHeight(50)))
		{
			if(!jointPositionsCreated)
			{
				bodyParts = new List<Transform>();
				jointPositions = new List<Transform>();
				
				if(head)
				{
					bodyParts.Add (head.transform);
					headJointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (headJointPosition);
				}

				if(neck)
				{
					bodyParts.Add (neck.transform);
					neckJointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (neckJointPosition);
				}

				if(spine)
				{
					bodyParts.Add (spine.transform);
					spineJointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (spineJointPosition);
				}

				if(upperArm1)
				{
					bodyParts.Add (upperArm1.transform);
					upperArm1JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (upperArm1JointPosition);
				}

				if(upperArm2)
				{
					bodyParts.Add (upperArm2.transform);
					upperArm2JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (upperArm2JointPosition);
				}

				if(lowerArm1)
				{
					bodyParts.Add (lowerArm1.transform);
					lowerArm1JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (lowerArm1JointPosition);
				}

				if(lowerArm2)
				{
					bodyParts.Add (lowerArm2.transform);
					lowerArm2JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (lowerArm2JointPosition);
				}

				if(wrist1)
				{
					bodyParts.Add (wrist1.transform);
					wrist1JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (wrist1JointPosition);
				}

				if(wrist2)
				{
					bodyParts.Add (wrist2.transform);
					wrist2JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (wrist2JointPosition);
				}

				if(thigh1)
				{
					bodyParts.Add (thigh1.transform);
					thigh1JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (thigh1JointPosition);
				}

				if(thigh2)
				{
					bodyParts.Add (thigh2.transform);
					thigh2JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (thigh2JointPosition);
				}

				if(leg1)
				{
	              	bodyParts.Add (leg1.transform);
					leg1JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (leg1JointPosition);
				}

				if(leg2)
				{
	               	bodyParts.Add (leg2.transform);
					leg2JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (leg2JointPosition);
				}

				if(foot1)
				{
					bodyParts.Add (foot1.transform);
					foot1JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (foot1JointPosition);
				}

				if(foot2)
				{
					bodyParts.Add (foot2.transform);
					foot2JointPosition = GameObject.CreatePrimitive (PrimitiveType.Quad).transform;
					jointPositions.Add (foot2JointPosition);
				}

				for(int i=0; i< jointPositions.Count; i++)
				{
					DestroyImmediate(jointPositions[i].GetComponent<Collider>());
					jointPositions[i].name = "Joint Position";
					
					jointPositions[i].parent = bodyParts[i];
					jointPositions[i].localPosition = new Vector3(0,0,-0.01f);
					jointPositions[i].localScale = bodyParts[i].localScale / 7;
				}

				if(jointPositions.Count > 0)
				{
					jointPositionsCreated = true;
					helpText = "JOINT POSITIONS ARE CREATED";
				}
				else helpText = "BODY PARTS AREN'T ASSIGNED";
			}
			else 
			{
				foreach(var child in jointPositions)
					DestroyImmediate (child.gameObject);

				jointPositionsCreated = false;
				helpText = "JOINT POSITIONS ARE DELETED";
			}
		}

		GUILayout.Space (5);

		//shows or hides joint position objects
		if(GUILayout.Button ((showJointPositions == false? "Show" : "Hide") + " Joint Positions", GUILayout.ExpandHeight(true), GUILayout.MinHeight (30), GUILayout.MaxHeight(50)))
		{
			if(jointPositionsCreated)
			{
				showJointPositions = !showJointPositions;

				foreach(var jointPos in jointPositions)
				{
					jointPos.GetComponent<Renderer>().enabled = showJointPositions == true? true : false;
				}

				if(showJointPositions)
					helpText = "JOINT POSITIONS ARE SHOWN";
				else
					helpText = "JOINT POSITIONS ARE HIDDEN";
			}
			else helpText = "JOINT POSITIONS AREN'T CREATED YET";
		}

		GUILayout.Space(5);

		//creates ragdoll
		//checks if body part have collider2D component, if it doesn't have it, adds it
		//checks for hingeJoint2D component, if it doesn't have it, adds it
		//sets connectedBody object, anchor and connectedAnchor positions and sets angle limits also use or not use those limits
		if(GUILayout.Button ("Create Ragdoll", GUILayout.ExpandHeight(true), GUILayout.MinHeight (30), GUILayout.MaxHeight(50)))
		{
			if(jointPositionsCreated)
			{
				if(!body)
				{
					helpText = "BODY MUST BE ASSIGNED";
					return;
				}

				if(!body.GetComponent<Rigidbody2D>())
				{
					body.AddComponent<Rigidbody2D>();
					if(!body.GetComponent<Collider2D>())
						body.AddComponent<PolygonCollider2D>();
				}


				var limit = new JointAngleLimits2D();

				if(neck)
				{
					//add collider 
					if(!neck.GetComponent<Collider2D>())
						neck.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var neckJoint = neck.GetComponent<HingeJoint2D>()? neck.GetComponent<HingeJoint2D>() : neck.AddComponent<HingeJoint2D>();
					neckJoint.connectedBody = body.GetComponent<Rigidbody2D>();
					neckJoint.anchor = neckJointPosition.localPosition;
					neckJoint.connectedAnchor = body.transform.InverseTransformPoint (neckJointPosition.position);
					
					//add lower and upper angle limits
					limit.min = int.Parse (neckLowerAngle);
					limit.max = int.Parse (neckUpperAngle);
					neckJoint.limits = limit;
					neckJoint.useLimits = neckUseLimit;
				}


				if(spine)
				{
					//add collider 
					if(!spine.GetComponent<Collider2D>())
						spine.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var spineJoint = spine.GetComponent<HingeJoint2D>()? spine.GetComponent<HingeJoint2D>() : spine.AddComponent<HingeJoint2D>();
					spineJoint.connectedBody = body.GetComponent<Rigidbody2D>();
					spineJoint.anchor = spineJointPosition.localPosition;
					spineJoint.connectedAnchor = body.transform.InverseTransformPoint (spineJointPosition.position);
					
					//add lower and upper angle limits
					limit.min = int.Parse (spineLowerAngle);
					limit.max = int.Parse (spineUpperAngle);
					spineJoint.limits = limit;
					spineJoint.useLimits = spineUseLimit;
				}


				if(head)
				{
					//add collider 
					if(!head.GetComponent<Collider2D>())
						head.AddComponent<PolygonCollider2D>();

					//add hinge joint 
					var headJoint = head.GetComponent<HingeJoint2D>()? head.GetComponent<HingeJoint2D>() : head.AddComponent<HingeJoint2D>();
					headJoint.connectedBody = neck? neck.GetComponent<Rigidbody2D>() : body.GetComponent<Rigidbody2D>();
					headJoint.anchor = headJointPosition.localPosition;
					headJoint.connectedAnchor = neck? neck.transform.InverseTransformPoint(headJointPosition.position) : body.transform.InverseTransformPoint (headJointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (headLowerAngle);
					limit.max = int.Parse (headUpperAngle);
					headJoint.limits = limit;
					headJoint.useLimits = headUseLimit;
				}
				


				if(upperArm1)
				{
					//add collider 
					if(!upperArm1.GetComponent<Collider2D>())
						upperArm1.AddComponent<PolygonCollider2D>();

					//add hinge joint 
					var upperArm1Joint =  upperArm1.GetComponent<HingeJoint2D>()? upperArm1.GetComponent<HingeJoint2D>() : upperArm1.AddComponent<HingeJoint2D>();
					upperArm1Joint.connectedBody = body.GetComponent<Rigidbody2D>();
					upperArm1Joint.anchor = upperArm1JointPosition.localPosition;
					upperArm1Joint.connectedAnchor = body.transform.InverseTransformPoint (upperArm1JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (upperArm1LowerAngle);
					limit.max = int.Parse (upperArm1UpperAngle);
					upperArm1Joint.limits = limit;
					upperArm1Joint.useLimits = upperArm1UseLimit;
				}
				

				if(upperArm2)
				{
					//add collider 
					if(!upperArm2.GetComponent<Collider2D>())
						upperArm2.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var upperArm2Joint = upperArm2.GetComponent<HingeJoint2D>()? upperArm2.GetComponent<HingeJoint2D>() : upperArm2.AddComponent<HingeJoint2D>();
					upperArm2Joint.connectedBody = body.GetComponent<Rigidbody2D>();
					upperArm2Joint.anchor = upperArm2JointPosition.localPosition;
					upperArm2Joint.connectedAnchor = body.transform.InverseTransformPoint (upperArm2JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (upperArm2LowerAngle);
					limit.max = int.Parse (upperArm2UpperAngle);
					upperArm2Joint.limits = limit;
					upperArm2Joint.useLimits = upperArm2UseLimit;
				}
				

				if(lowerArm1 && upperArm1)
				{
					//add collider 
					if(!lowerArm1.GetComponent<Collider2D>())
						lowerArm1.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var lowerArm1Joint = lowerArm1.GetComponent<HingeJoint2D>()? lowerArm1.GetComponent<HingeJoint2D>() : lowerArm1.AddComponent<HingeJoint2D>();
					lowerArm1Joint.connectedBody = upperArm1.GetComponent<Rigidbody2D>();
					lowerArm1Joint.anchor = lowerArm1JointPosition.localPosition;
					lowerArm1Joint.connectedAnchor = upperArm1.transform.InverseTransformPoint (lowerArm1JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (lowerArm1LowerAngle);
					limit.max = int.Parse (lowerArm1UpperAngle);
					lowerArm1Joint.limits = limit;
					lowerArm1Joint.useLimits = lowerArm1UseLimit;
				}
					

				if(lowerArm2 && upperArm2)
				{
					//add collider 
					if(!lowerArm2.GetComponent<Collider2D>())
						lowerArm2.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var lowerArm2Joint = lowerArm2.GetComponent<HingeJoint2D>()? lowerArm2.GetComponent<HingeJoint2D>() : lowerArm2.AddComponent<HingeJoint2D>();
					lowerArm2Joint.connectedBody = upperArm2.GetComponent<Rigidbody2D>();
					lowerArm2Joint.anchor = lowerArm2JointPosition.localPosition;
					lowerArm2Joint.connectedAnchor = upperArm2.transform.InverseTransformPoint (lowerArm2JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (lowerArm2LowerAngle);
					limit.max = int.Parse (lowerArm2UpperAngle);
					lowerArm2Joint.limits = limit;
					lowerArm2Joint.useLimits = lowerArm2UseLimit;
				}
				

				if(wrist1 && lowerArm1 && upperArm1)
				{
					//add collider 
					if(!wrist1.GetComponent<Collider2D>())
						wrist1.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var wrist1Joint = wrist1.GetComponent<HingeJoint2D>()? wrist1.GetComponent<HingeJoint2D>() : wrist1.AddComponent<HingeJoint2D>();
					wrist1Joint.connectedBody = lowerArm1.GetComponent<Rigidbody2D>();
					wrist1Joint.anchor = wrist1JointPosition.localPosition;
					wrist1Joint.connectedAnchor = lowerArm1.transform.InverseTransformPoint (wrist1JointPosition.position);
					
					//add lower and upper angle limits
					limit.min = int.Parse (wrist1LowerAngle);
					limit.max = int.Parse (wrist1UpperAngle);
					wrist1Joint.limits = limit;
					wrist1Joint.useLimits = wrist1UseLimit;
				}


				if(wrist2 && lowerArm2 && upperArm2)
				{
					//add collider 
					if(!wrist2.GetComponent<Collider2D>())
						wrist2.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var wrist2Joint = wrist2.GetComponent<HingeJoint2D>()? wrist2.GetComponent<HingeJoint2D>() : wrist2.AddComponent<HingeJoint2D>();
					wrist2Joint.connectedBody = lowerArm2.GetComponent<Rigidbody2D>();
					wrist2Joint.anchor = wrist2JointPosition.localPosition;
					wrist2Joint.connectedAnchor = lowerArm2.transform.InverseTransformPoint (wrist2JointPosition.position);
					
					//add lower and upper angle limits
					limit.min = int.Parse (wrist2LowerAngle);
					limit.max = int.Parse (wrist2UpperAngle);
					wrist2Joint.limits = limit;
					wrist2Joint.useLimits = wrist2UseLimit;
				}


				if(thigh1)
				{
					//add collider 
					if(!thigh1.GetComponent<Collider2D>())
						thigh1.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var thigh1Joint = thigh1.GetComponent<HingeJoint2D>()? thigh1.GetComponent<HingeJoint2D>() : thigh1.AddComponent<HingeJoint2D>();
					thigh1Joint.connectedBody = spine? spine.GetComponent<Rigidbody2D>() : body.GetComponent<Rigidbody2D>();
					thigh1Joint.anchor = thigh1JointPosition.localPosition;
					thigh1Joint.connectedAnchor = spine? spine.transform.InverseTransformPoint(thigh1JointPosition.position) : body.transform.InverseTransformPoint (thigh1JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (thigh1LowerAngle);
					limit.max = int.Parse (thigh1UpperAngle);
					thigh1Joint.limits = limit;
					thigh1Joint.useLimits = thigh1UseLimit;
				}
				

				if(thigh2)
				{
					//add collider 
					if(!thigh2.GetComponent<Collider2D>())
						thigh2.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var thigh2Joint = thigh2.GetComponent<HingeJoint2D>()? thigh2.GetComponent<HingeJoint2D>() : thigh2.AddComponent<HingeJoint2D>();
					thigh2Joint.connectedBody = spine? spine.GetComponent<Rigidbody2D>() : body.GetComponent<Rigidbody2D>();
					thigh2Joint.anchor = thigh2JointPosition.localPosition;
					thigh2Joint.connectedAnchor = spine? spine.transform.InverseTransformPoint(thigh2JointPosition.position) : body.transform.InverseTransformPoint (thigh2JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (thigh2LowerAngle);
					limit.max = int.Parse (thigh2UpperAngle);
					thigh2Joint.limits = limit;
					thigh2Joint.useLimits = thigh2UseLimit;
				}
				


				if(leg1 && thigh1)
				{
					//add collider 
					if(!leg1.GetComponent<Collider2D>())
						leg1.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var leg1Joint = leg1.GetComponent<HingeJoint2D>()? leg1.GetComponent<HingeJoint2D>() : leg1.AddComponent<HingeJoint2D>();
					leg1Joint.connectedBody = thigh1.GetComponent<Rigidbody2D>();
					leg1Joint.anchor = leg1JointPosition.localPosition;
					leg1Joint.connectedAnchor = thigh1.transform.InverseTransformPoint (leg1JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (leg1LowerAngle);
					limit.max = int.Parse (leg1UpperAngle);
					leg1Joint.limits = limit;
					leg1Joint.useLimits = leg1UseLimit;
				}
				



				if(leg2 && thigh2)
				{
					//add collider 
					if(!leg2.GetComponent<Collider2D>())
						leg2.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var leg2Joint = leg2.GetComponent<HingeJoint2D>()? leg2.GetComponent<HingeJoint2D>() : leg2.AddComponent<HingeJoint2D>();
					leg2Joint.connectedBody = thigh2.GetComponent<Rigidbody2D>();
					leg2Joint.anchor = leg2JointPosition.localPosition;
					leg2Joint.connectedAnchor = thigh2.transform.InverseTransformPoint (leg2JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (leg2LowerAngle);
					limit.max = int.Parse (leg2UpperAngle);
					leg2Joint.limits = limit;
					leg2Joint.useLimits = leg2UseLimit;
				}
				

				if(foot1 && leg1 && thigh1)
				{
					//add collider 
					if(!foot1.GetComponent<Collider2D>())
						foot1.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var foot1Joint = foot1.GetComponent<HingeJoint2D>()? foot1.GetComponent<HingeJoint2D>() : foot1.AddComponent<HingeJoint2D>();
					foot1Joint.connectedBody = leg1.GetComponent<Rigidbody2D>();
					foot1Joint.anchor = foot1JointPosition.localPosition;
					foot1Joint.connectedAnchor = leg1.transform.InverseTransformPoint (foot1JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (foot1LowerAngle);
					limit.max = int.Parse (foot1UpperAngle);
					foot1Joint.limits = limit;
					foot1Joint.useLimits = foot1UseLimit;
				}

				if(foot2 && leg2 && thigh2)
				{
					//add collider 
					if(!foot2.GetComponent<Collider2D>())
						foot2.AddComponent<PolygonCollider2D>();
					
					//add hinge joint 
					var foot2Joint = foot2.GetComponent<HingeJoint2D>()? foot2.GetComponent<HingeJoint2D>() : foot2.AddComponent<HingeJoint2D>();
					foot2Joint.connectedBody = leg2.GetComponent<Rigidbody2D>();
					foot2Joint.anchor = foot2JointPosition.localPosition;
					foot2Joint.connectedAnchor = leg2.transform.InverseTransformPoint (foot2JointPosition.position);

					//add lower and upper angle limits
					limit.min = int.Parse (foot2LowerAngle);
					limit.max = int.Parse (foot2UpperAngle);
					foot2Joint.limits = limit;
					foot2Joint.useLimits = foot2UseLimit;
				}

				helpText = "RAGDOLL WAS CREATED";
			}
			else
				helpText = "AT FIRST CREATE JOINT POSITIONS";
		}


		GUILayout.Space (5);

		//clears all assigned body parts for root object
		if(GUILayout.Button ("Reset", GUILayout.ExpandHeight(true), GUILayout.MinHeight (30), GUILayout.MaxHeight(50)))
		{
			showJointPositions = true;

			//clear body parts
			body = null;
			head = null;
			neck = null;
			spine = null;
			upperArm1 = null;
			upperArm2 = null;
			lowerArm1 = null;
			lowerArm2 = null;
			wrist1 = null;
			wrist2 = null;
			thigh1 = null;
			thigh2 = null;
			leg1 = null;
			leg2 = null;
			foot1 = null;
			foot2 = null;

			if(root)
			{
				var allParts = root.GetComponentsInChildren<Transform>();
				
				foreach(Transform child in allParts)
				{
					if(child.name == "Joint Position")
					{
						DestroyImmediate(child.gameObject);
					}
					else 
					{
						DestroyImmediate(child.GetComponent<Collider2D>());
						DestroyImmediate(child.GetComponent<HingeJoint2D>());
						DestroyImmediate(child.GetComponent<Rigidbody2D>());
					}
				}

				jointPositionsCreated = false;

				helpText = "RESETED";
			}
			else
				helpText = "ROOT OBJECT ISN'T ASSIGNED";
		}

		GUILayout.Space(10);
	}
 /// <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.JointAngleLimits2D jointAngleLimits2D = (UnityEngine.JointAngleLimits2D)value;
     writer.WriteProperty("min", jointAngleLimits2D.min);
     writer.WriteProperty("max", jointAngleLimits2D.max);
 }
    private static bool HandleMainLimits(HingeJoint2D hingeJoint2D, AnchorInfo anchorInfo, Color limitAreaColor,
        float limitDifference, Vector2 anchorPosition, float distanceFromCenter,
        float maxMainAngle, HingeJoint2DSettings settings, Color limitColor,
        float minMainAngle, Color angleWidgetColor, Color activeAngleColor,
        Color hoverAngleColor, float angleHandleSize, JointAngleLimits2D limits,
        float liveMainAngle)
    {
        var changed = false;
        using (new HandleColor(limitAreaColor)) {
            if (limitDifference > 360) {
                Handles.DrawSolidDisc(anchorPosition, Vector3.forward, distanceFromCenter);
            } else {
                Handles.DrawSolidArc(anchorPosition, Vector3.forward,
                    Helpers2D.GetDirection(maxMainAngle + settings.mainAngleOffset),
                    limitDifference, distanceFromCenter);
            }
        }
        using (new HandleColor(limitColor)) {
            Vector3 minMainEnd = anchorPosition +
                                 Helpers2D.GetDirection(minMainAngle + settings.mainAngleOffset) *
                                 distanceFromCenter;
            Handles.DrawLine(anchorPosition, minMainEnd);

            Vector3 maxMainEnd = anchorPosition +
                                 Helpers2D.GetDirection(maxMainAngle + settings.mainAngleOffset) *
                                 distanceFromCenter;
            Handles.DrawLine(anchorPosition, maxMainEnd);

            if (limitDifference > 360) {
                Handles.DrawWireDisc(anchorPosition, Vector3.forward, distanceFromCenter);
            } else {
                Handles.DrawWireArc(anchorPosition, Vector3.forward,
                    Helpers2D.GetDirection(maxMainAngle + settings.mainAngleOffset),
                    limitDifference, distanceFromCenter);
            }

            EditorGUI.BeginChangeCheck();
            using (
                HandleDrawerBase drawer = new HandleCircleDrawer(angleWidgetColor, activeAngleColor,
                    hoverAngleColor)) {
                minMainAngle = EditorHelpers.AngleSlider(anchorInfo.GetControlID("lowerMainAngle"), drawer,
                    anchorPosition,
                    minMainAngle + settings.mainAngleOffset,
                    distanceFromCenter, angleHandleSize * HandleUtility.GetHandleSize(minMainEnd) / 64) -
                               settings.mainAngleOffset;
            }

            if (EditorGUI.EndChangeCheck()) {
                EditorHelpers.RecordUndo("Change Angle Limits", hingeJoint2D);
                limits.min = Handles.SnapValue(liveMainAngle - minMainAngle, editorSettings.snapAngle);
                hingeJoint2D.limits = limits;
                changed = true;
            }

            EditorGUI.BeginChangeCheck();
            using (
                HandleDrawerBase drawer = new HandleCircleDrawer(angleWidgetColor,
                    activeAngleColor, hoverAngleColor)) {
                maxMainAngle = EditorHelpers.AngleSlider(anchorInfo.GetControlID("upperMainAngle"), drawer,
                    anchorPosition,
                    maxMainAngle + settings.mainAngleOffset,
                    distanceFromCenter, angleHandleSize * HandleUtility.GetHandleSize(maxMainEnd) / 64) -
                               settings.mainAngleOffset;
            }

            if (EditorGUI.EndChangeCheck()) {
                EditorHelpers.RecordUndo("Change Angle Limits", hingeJoint2D);
                limits.max = Handles.SnapValue(liveMainAngle - maxMainAngle, editorSettings.snapAngle);
                hingeJoint2D.limits = limits;
                changed = true;
            }
        }
        return changed;
    }
Ejemplo n.º 27
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.º 28
0
    /// <summary>
    /// Create and configure RopeSection
    /// </summary>
    GameObject CreateSection(int i, Rigidbody2D connectedBody) {
      GameObject section;
      float currentLocalYPos = -segmentLength / 2.0f - segmentLength * i;

      if (sectionPrefab != null) {
        section = (GameObject) GameObject.Instantiate(sectionPrefab);
      } else {
        section = new GameObject();
      }
      section.name = "RopeSection_" + i;
      section.layer = gameObject.layer;

      // Set length and position
      section.transform.parent = transform;
      section.transform.localPosition = new Vector3(0, currentLocalYPos, 0);

      Rigidbody2D rb = section.GetOrAddComponent<Rigidbody2D>();
      rb.mass = ropeMass;
      // NOTE this is mandatory atm.
      // the rope movement it's a bit basic, because i cannot have a more stable
      // version
      rb.isKinematic = true;

      BoxCollider2D bc2d = section.GetOrAddComponent<BoxCollider2D>();
      // Default to a 0.5f wide box collider
      bc2d.size = new Vector2(0.5f, segmentLength);
      bc2d.isTrigger = true;

      // Check Hinge Joint
      HingeJoint2D hingeJoint = section.GetOrAddComponent<HingeJoint2D>();
      hingeJoint.anchor = new Vector2(0, 0.5f);
      hingeJoint.connectedAnchor = new Vector2(0, i == 0 ? 0.0f : -0.5f);
      hingeJoint.connectedBody = connectedBody;
      if (angleLimits > 0) {
        hingeJoint.useLimits = true;
        JointAngleLimits2D limits = new JointAngleLimits2D();
        limits.min = angleLimits;
        limits.max = -angleLimits;
        hingeJoint.limits = limits;
      }

      // this will handle the player entering the rope
      RopeSection rs = section.AddComponent<RopeSection>();
      rs.rope = this;
      rs.index = i;

      if (health != null) {
        // NOTE add/get the HitBox so it can be destroyed
        // if we add a hitbox, it's just useless we need a proper collideWith
        // configured
        HitBox hitbox = section.GetOrAddComponent<HitBox>();
        hitbox.owner = health;
        //hitbox.type = HitBoxType.RecieveDamage;
        //hitbox.collideWith = recieveDamage;
      }

      // Special case, for last section
      if (i == segments - 1) {
        rb.mass = ropeMass * 5;
      }

      sections[i] = section;
      return section;
    }
Ejemplo n.º 29
0
 private extern void INTERNAL_set_limits(ref JointAngleLimits2D value);
Ejemplo n.º 30
0
	public void Apply () {
		isActive = true;
		skeleton = skeletonAnim.Skeleton;
		mix = 1;

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

		rootRigidbody = boneTable[ragdollRootBone].GetComponent<Rigidbody2D>();
		rootRigidbody.isKinematic = pinStartBone;
		rootRigidbody.mass = rootMass;

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

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

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

			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<Rigidbody2D>();

			if (rbParent != null) {
				var joint = t.gameObject.AddComponent<HingeJoint2D>();
				joint.connectedBody = rbParent;
				Vector3 localPos = parentTransform.InverseTransformPoint(t.position);
				localPos.x *= 1;
				joint.connectedAnchor = localPos;
				joint.GetComponent<Rigidbody2D>().mass = joint.connectedBody.mass * massFalloffFactor;
				JointAngleLimits2D limits = new JointAngleLimits2D();
				limits.min = -rotationLimit;
				limits.max = rotationLimit;
				joint.limits = limits;
				joint.useLimits = true;
			}
		}

		for (int x = 0; x < boneColliders.Count; x++) {
			for (int y = 0; y < boneColliders.Count; y++) {
				if (x == y) continue;
				Physics2D.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;
	}
Ejemplo n.º 31
0
 private extern void get_limits_Injected(out JointAngleLimits2D ret);