using UnityEngine;
using System.Collections;
public class SHC_CollisionManager : MonoBehaviour
{
GameObject tmp;
void Start()
{
tmp = (GameObject) Instantiate (new GameObject ("CollisionsWhyAreYouTormentingMe"),transform.position,transform.rotation);
tmp.transform.parent = transform;
}
void Update()
{
if(Input.GetKeyDown (KeyCode.C) || Input.GetKeyDown ("joystick button 8") && Input.GetKeyUp ("joystick button 3"))
{
Destroy (transform.GetChild (0).gameObject);
tmp = (GameObject) Instantiate (new GameObject ("CollisionsWhyAreYouTormentingMe"),transform.position,transform.rotation);
tmp.transform.parent = transform;
}
}
}
The following code is what i think should do is destroy the current child when i press C, and create a replacement. What it does however is it creates a Clone, sets it as child and then makes another game object in the scene Hierarchy? What am i missing here?

You’re creating a new GameObject and instantiating it. Use one or the other…Instantiate is generally for instantiating prefabs, and the GameObject constructor is for creating a new GameObject from scratch.