join two object when its near to each other
hi you can see in my video i try to combine two object see my video i done code like this FOR JOIN TWO OBJECT FOR TWELVE i calculating number value depends on sequences of tracking marker if marker one is track first so i concatenate 1 in number variable if marker two is loading after one i concatenate 2 in number variable so, value of number is 12 in this condition both joining but problem is when they put marker in opposite direction then they no combine but their position is changing in opposite direction thats why i want to find with object is left & right of each other i calculate number value and join them var o12d = Vector3.Distance(o1.transform.position, o2.transform.position);
if (o12d < twoobjdistance && number=="12") {
if(iscombine_12==false)
{
o1.transform.localPosition=new Vector3(o1.transform.localPosition.x+plushx,o1.transform.localPosition.y,o1.transform.localPosition.z);
o2.transform.localPosition=new Vector3(o2.transform.localPosition.x-subx,o2.transform.localPosition.y,o2.transform.localPosition.z);
iscombine_12=true;
}
} else
{
if(iscombine_12==true)
{
o1.transform.localPosition=new Vector3(0f,o1.transform.localPosition.y,o1.transform.localPosition.z);
o2.transform.localPosition=new Vector3(0f,o0.transform.localPosition.y,o0.transform.localPosition.z);
iscombine_12=false;
}
}
Your answer
Follow this Question
Related Questions
How does hinge joint work? 0 Answers
2D wrapping a line around a collision object 1 Answer
How to make two objects rotate around the axis of one object, when connected to a spring 0 Answers
Configurable Joint keeps wobbling without a reason 1 Answer
How to adjust xMotion on configurable joint via c# script? 2 Answers