Joint that allows a Rigidbody2D object to rotate around a point in space or a point on another object.

Inheritance: AnchoredJoint2D
Exemple #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>();
	}
Exemple #2
0
    public void Start()
    {
        // Center chain between the connected bodies
        transform.position = (bodyA.transform.position + bodyB.transform.position) / 2.0f;

        if (!isDuplicate)
        {
            // Attach to body A
            jointA = gameObject.AddComponent<HingeJoint2D>();
            jointA.connectedBody = bodyA;
            jointA.anchor = bodyA.transform.position - transform.position;
            jointA.connectedAnchor = offsetA;

            // Attach to body B
            jointB = gameObject.AddComponent<HingeJoint2D>();
            jointB.connectedBody = bodyB;
            jointB.anchor = bodyB.transform.position - transform.position;
            jointB.connectedAnchor = offsetB;
        }

        endA = bodyA.transform.position;
        endB = bodyB.transform.position;

        if (chainRenderer == null)
        {
            chainRenderer = GetComponent<ChainRenderer>();
        }

        // For some reason in 4.5.2, chains are getting stuck in some kind of fake-sleep mode unless you touch something...
        rigidbody2D.mass = rigidbody2D.mass;
    }
Exemple #3
0
 void Start()
 {
     obj = (GameObject)GameObject.Instantiate(obj);
     //		trailSub = transform.GetChild (0).gameObject;
     trail = obj.GetComponent<TrailRenderer>();
     player = transform.parent.transform.parent.gameObject;
     pMov = player.GetComponent<Player_Movement>();
     obj.collider2D.enabled = false;
     obj.transform.parent = transform;
     obj.GetComponent<HingeJoint2D>().anchor = new Vector2(-0.5f, 0);
     obj.GetComponent<HingeJoint2D>().connectedBody = player.rigidbody2D;
     obj.collider2D.enabled = true;
     objMid = obj.GetComponentInChildren<GrapplingStalk>();
     obj.SetActive(false);
     end = (GameObject)GameObject.Instantiate(end);
     end.transform.parent = transform.parent;
     endScript = end.GetComponent<GrapplingEnd>();
     endScript.setLayersToGrapple(possibleLayers);
     endScript.Setup(obj);
     endJoint = obj.AddComponent<HingeJoint2D>();
     endJoint.anchor = new Vector2(0.5f, 0);
     endJoint.connectedBody = end.rigidbody2D;
     lasCon = obj.GetComponent<laserConnector>();
     lasCon.endPoint = end.transform;
     lasCon.startPoint = transform.parent;
     lasCon.player = player.transform;
 }
Exemple #4
0
 static public int set_useMotor(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.HingeJoint2D self = (UnityEngine.HingeJoint2D)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.useMotor = v;
         pushValue(l, true);
         return(1);
     }
     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
 }
Exemple #5
0
 static public int get_limitState(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.HingeJoint2D self = (UnityEngine.HingeJoint2D)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.limitState);
         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
 }
Exemple #6
0
 public void MakeHingeJoint(Rigidbody2D targetBody, Vector2 position, Vector2 connectedPosition)
 {
     stickHJ = gameObject.AddComponent<HingeJoint2D>();
     stickHJ.connectedBody = targetBody;
     stickHJ.anchor = transform.InverseTransformPoint(position);
     stickHJ.connectedAnchor = connectedPosition;
 }
Exemple #7
0
    public void ResetProjectile()
    {
        if (grappleJoint)
        {
            Destroy(grappleJoint);
            grappleJoint = null;
        }

        if (body)
        {
            body.isKinematic = true;
            Destroy(body);
            body = null;
        }

        if (parent)
        {
            transform.parent = parent;
        }

        transform.localEulerAngles = Vector3.zero;
        transform.localPosition = Vector3.zero;
        transform.localScale = Vector3.one;

        AttachedToPoint = false;

        clampSprite.sprite = collapsedSprite;
    }
 void Start()
 {
     hinge = GetComponent<HingeJoint2D>();
     JointMotor2D motor = hinge.motor;//.motorSpeed = MotorSpeed;
     motor.motorSpeed = MotorSpeed;
     hinge.motor = motor;
 }
Exemple #9
0
	//get transform and HingeJoint2D information from this joint's connected object
	void GetConnectedObject()
	{
		connectedObject = joint.connectedBody.transform;
		connectedJoint = connectedObject.GetComponent<HingeJoint2D>();

		jointGot = true;
	}
    // Use this for initialization
    void Start()
    {
        trapDoor = gameObject;
        transform.parent.gameObject.GetComponent<PuzzleScript>().SendMessage ("addReceiverObject", trapDoor, SendMessageOptions.DontRequireReceiver);

        joint = trapDoor.GetComponent<HingeJoint2D>();
    }
Exemple #11
0
    // Update is called once per frame
    void Update()
    {
        bool grab = Input.GetButtonDown("Fire1");

        if (grab) {

            if( grabJoint ){
                Destroy( grabJoint );
            }else{
                Collider2D[] objects = Physics2D.OverlapCircleAll( transform.position, grabRadious );
                foreach( Collider2D col in objects ){
                    if( col.transform.CompareTag("Grabable") ){
                        BodyPart part = col.transform.gameObject.GetComponent<BodyPart>();
                        if( part ){
                            part.SetGrabbed();
                            grabJoint = part.gameObject.AddComponent<HingeJoint2D>();
                            Rigidbody2D r = GetComponent<Rigidbody2D>();
                            grabJoint.connectedBody = r;
                            return;
                        }
                    }

                }
            }
        }
    }
    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;
    }
Exemple #13
0
 void Start()
 {
     hj = GetComponent<HingeJoint2D>();
     motor.maxMotorTorque = 1000;
     motor.motorSpeed = 100;
     hj.motor = motor;
 }
Exemple #14
0
 protected override void Start()
 {
     base.Start ();
     mHingeJoint = GetComponent<HingeJoint2D> ();
     mHalfAngleLimits = (int)((mHingeJoint.limits.max - mHingeJoint.limits.min) / 2);
     mHalfAngleLimits = Mathf.Abs (mHalfAngleLimits);
     mTrigger = GetComponent<Trigger> ();
 }
    void Awake()
    {
        DontDestroyOnLoad(gameObject);

        hinge = GetComponent<HingeJoint2D> ();
        hinge.enabled = false;
        hinge.anchor = new Vector2 (playerHand.localPosition.x, playerHand.localPosition.y);
    }
Exemple #16
0
	// Use this for initialization
	void Start () {
		chain = new GameObject[11];
		jointGroot = GetComponent<HingeJoint2D> ();
		terrains = GameObject.FindGameObjectsWithTag("terrain");
		spider = GameObject.Find("/root/spider");
		berry = GameObject.Find("/root/berry");

	}
 // Use this for initialization
 void Start()
 {
     Nave = GameObject.FindGameObjectWithTag ("Player");
     joint = GetComponent<HingeJoint2D> ();
     joint.connectedBody = Nave.GetComponent<Rigidbody2D>();
     int mult = Camera.main.GetComponent<Contadores>().GetNaves() / 2;
     joint.anchor = new Vector2 (joint.anchor.x * (mult+1), 0);
     Camera.main.GetComponent<Contadores>().ContaNaves();
 }
 // Use this for initialization
 void Start()
 {
     hinge = GetComponentInChildren<HingeJoint2D>();
     //motor = hinge.motor;
     motor.maxMotorTorque = 5000;
     motor.motorSpeed = 120;
     swingingLeft = true;
     pendulumCollider = GetComponentInChildren<BoxCollider2D>();
 }
Exemple #19
0
    void ChangePart(HingeJoint2D part, bool positive)
    {
        float min = positive ? 0f : -MOTOR_SPEED;
        float max = positive ? MOTOR_SPEED : 0f;

        var motor = part.motor;
        motor.motorSpeed = Random.Range(min, max);
        part.motor = motor;
    }
 void Start()
 {
     startPoint = transform.position;
     body = GetComponent<Rigidbody2D>();
     jointMotor = new JointMotor2D();
     jointMotor.maxMotorTorque = 10000f;
     wheelJoint = GetComponent<HingeJoint2D>();
     wheelJoint.useMotor = true;
     //wheelJoint.motor = jointMotor;
 }
Exemple #21
0
 // Use this for initialization
 void Start()
 {
     _hinge = gameObject.GetComponent<HingeJoint2D>();
     if (_hinge == null) {
         enabled = false;
     }
     else {
         AnchorX = _hinge.connectedAnchor.x;
         AnchorY = _hinge.connectedAnchor.y;
     }
 }
 static public int get_motor(IntPtr l)
 {
     try {
         UnityEngine.HingeJoint2D self = (UnityEngine.HingeJoint2D)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.motor);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_limitState(IntPtr l)
 {
     try {
         UnityEngine.HingeJoint2D self = (UnityEngine.HingeJoint2D)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.limitState);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
	static public int constructor(IntPtr l) {
		try {
			UnityEngine.HingeJoint2D o;
			o=new UnityEngine.HingeJoint2D();
			pushValue(l,true);
			pushValue(l,o);
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
	}
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.HingeJoint2D o;
         o=new UnityEngine.HingeJoint2D();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.HingeJoint2D o;
         o = new UnityEngine.HingeJoint2D();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_motor(IntPtr l)
 {
     try {
         UnityEngine.HingeJoint2D self = (UnityEngine.HingeJoint2D)checkSelf(l);
         UnityEngine.JointMotor2D v;
         checkValueType(l, 2, out v);
         self.motor = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int set_useLimits(IntPtr l)
 {
     try {
         UnityEngine.HingeJoint2D self = (UnityEngine.HingeJoint2D)checkSelf(l);
         bool v;
         checkType(l, 2, out v);
         self.useLimits = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 // 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;
 }
 static void HingeJoint2D_useLimits(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.HingeJoint2D _this = (UnityEngine.HingeJoint2D)vc.csObj;
         var result = _this.useLimits;
         JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
     }
     else
     {
         System.Boolean           arg0  = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
         UnityEngine.HingeJoint2D _this = (UnityEngine.HingeJoint2D)vc.csObj;
         _this.useLimits = arg0;
     }
 }
 static public int GetMotorTorque(IntPtr l)
 {
     try {
         UnityEngine.HingeJoint2D self = (UnityEngine.HingeJoint2D)checkSelf(l);
         System.Single            a1;
         checkType(l, 2, out a1);
         var ret = self.GetMotorTorque(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemple #32
0
	// Use this for initialization
	void Start () {
		counter = 0;
		counterblood =0;
		BoxCollider2D[] myColliders = gameObject.GetComponents<BoxCollider2D>();
		foreach (BoxCollider2D bc in myColliders) {
			counter = counter + 1;
			if(counter > 1){
			Destroy(bc);
			}
		}
		distance = 0;
		//get hingejoint2D and rigidbody2D components from object on which this script is assigned
		joint = GetComponent<HingeJoint2D>();
		rb = GetComponent<Rigidbody2D>();
	}
 static public int GetMotorTorque(IntPtr l)
 {
     try{
         UnityEngine.HingeJoint2D self = (UnityEngine.HingeJoint2D)checkSelf(l);
         System.Single            a1;
         checkType(l, 2, out a1);
         System.Single ret = self.GetMotorTorque(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 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;
     }
 }
Exemple #35
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);
	}
Exemple #36
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);
	}
Exemple #37
0
    public void Grab(Rigidbody2D torsoRB, Rigidbody2D leftArmRB, Rigidbody2D rightArmRB,Vector2 handOffset)
    {
        LeftHinge = gameObject.AddComponent<HingeJoint2D>();
        LeftHinge.connectedBody = leftArmRB;
        LeftHinge.anchor = new Vector2(0f, 0f);
        LeftHinge.connectedAnchor = handOffset;

        RightHinge = gameObject.AddComponent<HingeJoint2D>();
        RightHinge.connectedBody = rightArmRB;
        RightHinge.anchor = new Vector2(0f, -0.3f);
        RightHinge.connectedAnchor = handOffset;

        RootHinge = Root.gameObject.AddComponent<HingeJoint2D>();
        RootHinge.connectedBody = torsoRB;
        float offset = 1.3f * (Root.transform.position.y - transform.position.y);
        RootHinge.connectedAnchor = new Vector2(1.2f, offset);
    }
Exemple #38
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.HingeJoint2D hingeJoint2D = (UnityEngine.HingeJoint2D)value;
     writer.WriteProperty("useMotor", hingeJoint2D.useMotor);
     writer.WriteProperty("useLimits", hingeJoint2D.useLimits);
     writer.WriteProperty("motor", hingeJoint2D.motor);
     writer.WriteProperty("limits", hingeJoint2D.limits);
     writer.WriteProperty("anchor", hingeJoint2D.anchor);
     writer.WriteProperty("connectedAnchor", hingeJoint2D.connectedAnchor);
     writer.WriteProperty("autoConfigureConnectedAnchor", hingeJoint2D.autoConfigureConnectedAnchor);
     writer.WriteProperty("connectedBody", hingeJoint2D.connectedBody);
     writer.WriteProperty("enableCollision", hingeJoint2D.enableCollision);
     writer.WriteProperty("breakForce", hingeJoint2D.breakForce);
     writer.WriteProperty("breakTorque", hingeJoint2D.breakTorque);
     writer.WriteProperty("enabled", hingeJoint2D.enabled);
     writer.WriteProperty("tag", hingeJoint2D.tag);
     writer.WriteProperty("name", hingeJoint2D.name);
     writer.WriteProperty("hideFlags", hingeJoint2D.hideFlags);
 }
Exemple #39
0
	//private bool timePauseAnimation = 0;

	void Start () {
		berry = GameObject.Find("berry");

		chain = new GameObject[100];
		maxDiffC = chainLength * maxChainCount;
		jointWeb = web.GetComponent<HingeJoint2D> ();
		if (pointB != null) {
			if (pointB.name == "berry") webStateCollisionBerry = true;
			if (pointB.name == "spider") gSpiderClass.websSpider.Add(gameObject.GetInstanceID());
			diff = pointB.transform.position + pointBAchor - web.transform.position;
			float pointBDiffC = Mathf.Sqrt(diff.x * diff.x + diff.y * diff.y);
			diffX = maxDiffC / pointBDiffC * diff.x / maxChainCount;
			diffY = maxDiffC / pointBDiffC * diff.y / maxChainCount;
			webState = "creatingWeb";
			while (webState == "creatingWeb") {
				createWeb(pointB.transform.position, pointBAchor, true);

				int i = chainCount;
				//chain[i].rigidbody2D.fixedAngle = true;
				if (pointB.GetComponent<Collider2D>().OverlapPoint(chain[1].transform.position + new Vector3(diffX, diffY, 0)) ||
				    pointB.GetComponent<Collider2D>().OverlapPoint(chain[1].transform.position + new Vector3(diffX/2, diffY/2, 0))) {

					chainCount = i;
					HingeJoint2D jointChain = chain[1].GetComponent<HingeJoint2D> ();
					jointChain.connectedBody = pointB.GetComponent<Rigidbody2D>();
					jointChain.connectedAnchor = pointBAchor * 1024;
					jointChain.enabled = true;	
					jointChain.useLimits = false;
					for (int y = 1; y <= chainCount; y ++){
						chain[y].GetComponent<Rigidbody2D>().drag = drag;
						chain[y].GetComponent<BoxCollider2D>().enabled = true;
						//chain[y].rigidbody2D.angularDrag = 2;
						//chain[y].rigidbody2D.centerOfMass = new Vector2(0, -0.3F);
					}

					//i = maxChainCount / 2;
					webState = "enableWeb";

				}
			}
		}
	}
Exemple #40
0
	//called when script is enabled
	void OnEnable ()
	{
		//reset variables
		broken = false;
		jointGot = false;
		breakCount = 0;

		//save components in variables to use them in update function, good for optimization
		if(tr == null)
			tr = transform;

		//save this and connected chain's HingeJoint2D component and connected chains transform too, to use in angle calculation
		if(joint == null)
			joint = GetComponent<HingeJoint2D>();

		if(!limitBreakCount)
			maxBreakCount =	breakCount + 1;

		time = Time.time;
	}
    private GameObject initRopePiece()
    {
        GameObject ropePiece = new GameObject (ROPE_PIECE_OBJECT_NAME);

        if (ropePieceSprite != null) {
            ropePieceSpriteRenderer = ropePiece.AddComponent<SpriteRenderer>();
            ropePieceRigidbody = ropePiece.AddComponent<Rigidbody2D>();
            ropePieceJoint = ropePiece.AddComponent<HingeJoint2D>();

            ropePieceSpriteRenderer.sprite = ropePieceSprite;

            ropePieceRigidbody.mass = pieceMass;
            ropePieceRigidbody.gravityScale = pieceGravityScale;
            ropePieceRigidbody.angularDrag = pieceDrag;

            ropePieceJoint.anchor = new Vector2(0, (ropePieceHeight / 2) + ropePieceCenterY);
        } else
            Debug.Log ("Please add sprite object to script (it's necessary)");

        return ropePiece;
    }
        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();
            }
        }
 static public int get_useLimits(IntPtr l)
 {
     UnityEngine.HingeJoint2D o = (UnityEngine.HingeJoint2D)checkSelf(l);
     pushValue(l, o.useLimits);
     return(1);
 }
Exemple #44
0
 /// <summary>
 ///   <para>Gets the motor torque of the joint given the specified timestep.</para>
 /// </summary>
 /// <param name="timeStep">The time to calculate the motor torque for.</param>
 public float GetMotorTorque(float timeStep)
 {
     return(HingeJoint2D.INTERNAL_CALL_GetMotorTorque(this, timeStep));
 }
Exemple #45
0
 private static void HingeJoint2D_CUSTOM_INTERNAL_GetReactionForce(HingeJoint2D joint, float timeStep, out Vector2 value)
 {
     throw new NotImplementedException("なにこれ");
 }
Exemple #46
0
 /// <summary>
 /// Read the data using the reader.
 /// </summary>
 /// <param name="reader">Reader.</param>
 public override object Read(ISaveGameReader reader)
 {
     UnityEngine.HingeJoint2D hingeJoint2D = SaveGameType.CreateComponent <UnityEngine.HingeJoint2D> ();
     ReadInto(hingeJoint2D, reader);
     return(hingeJoint2D);
 }
Exemple #47
0
        /// <summary>
        /// Read the data into the specified value.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="reader">Reader.</param>
        public override void ReadInto(object value, ISaveGameReader reader)
        {
            UnityEngine.HingeJoint2D hingeJoint2D = (UnityEngine.HingeJoint2D)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "useMotor":
                    hingeJoint2D.useMotor = reader.ReadProperty <System.Boolean> ();
                    break;

                case "useLimits":
                    hingeJoint2D.useLimits = reader.ReadProperty <System.Boolean> ();
                    break;

                case "motor":
                    hingeJoint2D.motor = reader.ReadProperty <UnityEngine.JointMotor2D> ();
                    break;

                case "limits":
                    hingeJoint2D.limits = reader.ReadProperty <UnityEngine.JointAngleLimits2D> ();
                    break;

                case "anchor":
                    hingeJoint2D.anchor = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "connectedAnchor":
                    hingeJoint2D.connectedAnchor = reader.ReadProperty <UnityEngine.Vector2> ();
                    break;

                case "autoConfigureConnectedAnchor":
                    hingeJoint2D.autoConfigureConnectedAnchor = reader.ReadProperty <System.Boolean> ();
                    break;

                case "connectedBody":
                    if (hingeJoint2D.connectedBody == null)
                    {
                        hingeJoint2D.connectedBody = reader.ReadProperty <UnityEngine.Rigidbody2D> ();
                    }
                    else
                    {
                        reader.ReadIntoProperty <UnityEngine.Rigidbody2D> (hingeJoint2D.connectedBody);
                    }
                    break;

                case "enableCollision":
                    hingeJoint2D.enableCollision = reader.ReadProperty <System.Boolean> ();
                    break;

                case "breakForce":
                    hingeJoint2D.breakForce = reader.ReadProperty <System.Single> ();
                    break;

                case "breakTorque":
                    hingeJoint2D.breakTorque = reader.ReadProperty <System.Single> ();
                    break;

                case "enabled":
                    hingeJoint2D.enabled = reader.ReadProperty <System.Boolean> ();
                    break;

                case "tag":
                    hingeJoint2D.tag = reader.ReadProperty <System.String> ();
                    break;

                case "name":
                    hingeJoint2D.name = reader.ReadProperty <System.String> ();
                    break;

                case "hideFlags":
                    hingeJoint2D.hideFlags = reader.ReadProperty <UnityEngine.HideFlags> ();
                    break;
                }
            }
        }
Exemple #48
0
 private static extern float INTERNAL_CALL_GetMotorTorque(HingeJoint2D self, float timeStep);
Exemple #49
0
 private static extern void HingeJoint2D_CUSTOM_INTERNAL_GetReactionForce(HingeJoint2D joint, float timeStep, out Vector2 value);
 static public int get_motor(IntPtr l)
 {
     UnityEngine.HingeJoint2D o = (UnityEngine.HingeJoint2D)checkSelf(l);
     pushValue(l, o.motor);
     return(1);
 }
 static public int get_limitState(IntPtr l)
 {
     UnityEngine.HingeJoint2D o = (UnityEngine.HingeJoint2D)checkSelf(l);
     pushEnum(l, (int)o.limitState);
     return(1);
 }
 static public int get_referenceAngle(IntPtr l)
 {
     UnityEngine.HingeJoint2D o = (UnityEngine.HingeJoint2D)checkSelf(l);
     pushValue(l, o.referenceAngle);
     return(1);
 }
 static public int get_jointSpeed(IntPtr l)
 {
     UnityEngine.HingeJoint2D o = (UnityEngine.HingeJoint2D)checkSelf(l);
     pushValue(l, o.jointSpeed);
     return(1);
 }
Exemple #54
0
 private static float INTERNAL_CALL_GetMotorTorque(HingeJoint2D self, float timeStep)
 {
     throw new NotImplementedException("なにこれ");
 }
 public override void OnEnable() => Component = gameObject.GetComponent <UnityEngine.HingeJoint2D>();