ObjectInfo GenerateGameObject(ButtonData data) { Transform generatedObject = (Transform)Instantiate(objectTemplate, transform.position, transform.rotation) as Transform; Debug.Log(generatedObject.name); Rigidbody body = generatedObject.gameObject.AddComponent <Rigidbody>(); body.mass = 1000; ObjectInfo generatedObjectInfo = generatedObject.GetComponent <ObjectInfo>(); generatedObjectInfo.ChangeObjectInfo(data); if (spawnPoint != null) { spawnPoint = transform.GetChild(0); } generatedObject.transform.position = new Vector3(spawnPoint.position.x, spawnPoint.position.y, spawnPoint.position.z); generatedObject.transform.parent = ObjectOrganizer; body.AddForce(GenerateForce()); return(generatedObjectInfo); }