I need a way in game to take two rigidodies in the world and fuse them together, i need them to work as one object, so parenting wont work. After than i take that object and i save it to a prefab i have. then i can freely spawn that prefab in the world. The spawning works and saving to prefab works, i just need a way of fusing to objects to eachother and act as if they were one(both moving relative to the other and shareing colliders.)
heres my code:
var changeto: GameObject;
function Update () {
if(Input.GetMouseButtonDown(0))
{
var INHAND : GameObject;
INHAND = Instantiate(AssetDatabase.LoadAssetAtPath("Assets/ball.prefab",GameObject),transform.position,transform.rotation) as GameObject;
INHAND.rigidbody.velocity = transform.TransformDirection (Vector3.forward * 2);
}
if(Input.GetMouseButtonDown(1))
{
var hit : RaycastHit;
if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), hit))
{
Debug.Log(hit.collider.name);
changeto=hit.transform.gameObject;
}
PrefabUtility.ReplacePrefab(changeto,AssetDatabase.LoadAssetAtPath("Assets/ball.prefab",Rigidbody), ReplacePrefabOptions.ConnectToPrefab);
}
}