Photonで、生成されたゲームオブジェクトを追う

たぶん、名前が重複してうまく動きません。生成時に名前を変更するのが必用。

using Photon.Pun;
using Photon.Realtime;
using UnityEngine;

// MonoBehaviourではなくMonoBehaviourPunCallbacksを継承して、Photonのコールバックを受け取れるようにする
public class SampleScene : MonoBehaviourPunCallbacks
{

    //follow_camスクリプトがついているGameObjectをインスペクターでセットする用
    public GameObject myCam;
    //作成されたオブジェクトを入れる
    GameObject instanceObj;

    //follow_camスクリプトをanotehrScriptとして読み込む
    [SerializeField] private follow_cam anotherScript;

    private void Start()
    {
        // PhotonServerSettingsに設定した内容を使ってマスターサーバーへ接続する
        PhotonNetwork.ConnectUsingSettings();
    }

    // マスターサーバーへの接続が成功した時に呼ばれるコールバック
    public override void OnConnectedToMaster()
    {
        // "room"という名前のルームに参加する(ルームが無ければ作成してから参加する)
        PhotonNetwork.JoinOrCreateRoom("room", new RoomOptions(), TypedLobby.Default);
    }

    // マッチングが成功した時に呼ばれるコールバック
    public override void OnJoinedRoom()
    {
        // マッチング後、ランダムな位置に自分自身のネットワークオブジェクトを生成する
        var v = new Vector3(Random.Range(-3f, 3f), Random.Range(-3f, 3f));

        //生成し、instanceObjに入れる※オンライン対戦させると同じ名前になるので、名前を変更する必用があるかも?
        instanceObj = PhotonNetwork.Instantiate("car_prefab", v, Quaternion.identity);

        //myCamにアサインされているgameobjectのfollow_camスクリプトをanotherScriptとする
        anotherScript = myCam.GetComponent < follow_cam > ();
        //anotherScript(実際にはfollow_cam)の変数のTaget(型はTransform)に、37行目で生成したinstanceObjのTransform(型を合わせる)をセットすする
        anotherScript.Target = instanceObj.transform;
    }



}