Legacy Documentation: Version 5.3
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Joint2D.OnJointBreak2D(Joint2D)

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Called when a Joint2D attached to the same game object breaks.

When the reactionForce is higher than the breakForce or the reactionTorque is higher than the breakTorque of the joint, the joint will break. When the joint breaks, OnJointBreak2D will be called and the specific Joint2D that broke will be passed in. After OnJointBreak2D is called, the joint will automatically be removed from the game object and deleted.

See Also: breakForce, breakTorque, reactionForce and reactionTorque.

#pragma strict
function OnJointBreak2D(brokenJoint: Joint2D) {
	Debug.Log("A joint has just been broken!");
	Debug.Log("The broken joint exerted a reaction force of " + brokenJoint.reactionForce);
	Debug.Log("The broken joint exerted a reaction torque of " + brokenJoint.reactionTorque);
}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void OnJointBreak2D (Joint2D brokenJoint) { Debug.Log ("A joint has just been broken!"); Debug.Log ("The broken joint exerted a reaction force of " + brokenJoint.reactionForce); Debug.Log ("The broken joint exerted a reaction torque of " + brokenJoint.reactionTorque); } }