How to null children of main camera that is also a child?

var start: Transform; // drag here the start empty object
var end: Transform; // drag here the end empty object
var duration: float = 1.6; // set duration of movement
var isNotDead:boolean=true;
var showGameOverScreenLboolean=false;

function Update(){
    // other things that you don't want the player to do while dead here
      isNotDead = false;
function DeathCamera(){
  var cam: Transform = Camera.main.transform; // get camera transform
  cam.parent = null; // detach it from the player
  cam.position = start.position; // place the camera at the start position
  cam.LookAt(end.position); // make it look towards the end position
  var t: float = 0;
  while (t < 1){
    t += Time.deltaTime/duration;
    // move the camera towards the end position each frame
    cam.position = Vector3.Lerp(start.position, end.position, t);
    yield; // let Unity do other jobs til next frame
  // movement ended - enable game over screen
  showGameOverScreen = true; // enable "Game Over" message in OnGUI
function KillPlayer(){
  DeathCamera(); // start DeathCamera coroutine
  // not sure if the line below effectively stops the player...
  GetComponent(CharacterController).enabled=false; //makes the player unable to move
  //Other things here - showGameOverScreen is activated by DeathCamera
function OnGUI(){
    //GUI code with whatever you want to have at the death screen.

So I have recently gotten this awesome script. The issue I’m having is that once the camera move towards my Monster’s face from death, children of the Main Camera also follow the camera. I have spotlights with a flashlight under the Main Camera, and I’m trying to null the children of the camera, which is also a child of the First Person Control Player. Of course seeing your flashlight randomly flying towards the Monster as you died looks ridiculous. Any help would be great! :slight_smile:

What do you mean by ‘null the parent’? Setting the transform.parent to null makes it a top-level object. Are you saying you want to ‘detach’ things that are children of the object the camera is on? If so:

for (var t : Transform in Camera.main.transform)
  t.parent = null;