Question by
santosxz20 · Oct 20, 2015 at 02:34 PM ·
fixedjoint
FixedJoint
I make transporter car gamei have 6 gameobjects(cars) with tag Player how can i do that any gameobject(car) enter to the collision(transporter) and when it enter create FixedJoint to object(car and transpoorter)??
using UnityEngine; using System.Collections;
public class Enter : MonoBehaviour {
public Transform Group1;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag=="Player")
{
collision.transform.parent = Group1;
if(collision.rigidbody != null)
{
var joint = gameObject.AddComponent<FixedJoint>();
joint.connectedBody = Group1.rigidbody;
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
How can I make the Gameobject fall down when the fixed joint connected body is destroyed? 1 Answer
Help with Fixed Joint , where the joint has a weird behavior. 0 Answers
FixedJoint2D 0 Answers
How to make two objects with seperate FixedJoints collide? 0 Answers
Fixed object direction while another object is rotating 0 Answers