Question by
Tobias234 · Jan 26 at 07:49 PM ·
scripting problemobject3dmodel
How can I use a scribt two combine two objects on collision with fixedjoint?
I want to connect two objects when they collide with each other. I have tried it with SetParent
but then the objects didn't stick together and my work with fixed joint hasn't lead to results. Does anyone have an idea?
This is my code till now:
public class test2 : MonoBehaviour
{
public GameObject li;
//public GameObject li;
void OnCollisionEnter ( Collision col )
{
if (col.transform.gameObject == li)
{
li.Parent = gameObject;
}
//ZweiterTest
//FixedJoint fj = tri.AddComponent<FixedJoint>() as FixedJoint;
//fj.connectedBody = li.Rigidbody;
//Erster Test
// public gameobject yellow;
// public gameobject black;
//GameObject player = collision.gameObject;
//transform.SetParent(player.transform);
// Yellow_Piece2.transform.parent = Black_Piece2.transform;
}
}
Comment
Your answer
Follow this Question
Related Questions
Cant find text objects after being renamed. 1 Answer
enabling item after the other one is disabled and so on? 0 Answers
How to get only one object to select at a time (in game)? 1 Answer
Trying to make an object appear in a position, but only if that position isn't occupied. 0 Answers
Script doesnt work properly on 1 object 0 Answers