I have multiple WheelJoint2D components on a gameobject. How would I go about removing a specific one of those WheelJoint2Ds?
Unless you maintain a reference to each component such as:
public class MyComponent : MonoBehaviour{
public WheelJoint2D WheelJointOne; //You can set this from the inspector
public WheelJoint2D WheelJointTwo; //You can set this from the inspector
}
The best you can do is get all instances of that component and then filter the results based on known properties:
public void SomeFunction(){
WheelJoint2D[] wheels = GetComponents<WheelJoint2D>();
foreach (WheelJoint2D w in wheels){
//Find the joint that matches some parameters, then you can delete it.
}
}
The filtering method is not ideal because it can be pretty hard to differentiate between two instances of a component some times, but it is possible in some cases. Assigning references within the inspector using public variables is really the easiest way to get things right.