Hello, so what im trying to do is make a camera a child of a game object. what I have is a perfab of a cube with its movement scripts and what not attached to it and also the camera harness gameObject which is just and empty gameObject. What I want to do when I spawn the perfab into the world I want the main camera to follow the cube. So I want it to be a child of the camera harness gameObject. I dont get any errors when I run this but the camera does not follow the cube when its moves. I dont know if I parented the camera right or not
Here are the variables that are being used
var playerPrefab : GameObject;
var cam : Camera;
and here is where I parent I think.
//spawn player prefab
function spawnPlayer()
{
Network.Instantiate(playerPrefab, sp1.position, Quaternion.identity, 0);
//camHolder is the parent
// Get the transform of the camera
cam.transform.parent = playerPrefab.GetComponent("CamHarness");
}
Thanks for any help with this