Networked FindParent

How can i find the original parent of the object.

Since i have smoothfollow.cs script on the camera and the target is the player that isnt spawned yet. so the target is now set to “Point”

So i created a empty gameobject named “Point”, the object is in the player and on the outside of the player.

And i need a script that finds the original “Point” gameobject so then the camera will follow the players “Point”

Best solution is to have a variable that keeps the parent stored. Based on GameObject.Find()

JS:

var parentObject : GameObject;

function Start(){
	parentObject = GameObject.Find("NameOfTheObjectAsString");
}

C#:

using UnityEngine;
using System.Collections;
    
public class ClassAndScriptName : MonoBehaviour {
GameObject parentObject;
    
    void Start(){
	parentObject = GameObject.Find("NameOfTheObjectAsString");
    }
}

Altertively you can use the GameObject.Find during runtime. However the .Find() function can be quite heavy computationally as it checks every GameObject in the scene (which in larger project can mount to quite a bit).

I hope this can help you a bit.