So, first of all, i am pretty new to unity, and I am trying to create a multiplayer game using photon.
I have a script that spawns two players at the start of the scene, and I need to use them as the LookAt and Follow, but I keep getting back this error:
NullReferenceException: Object reference not set to an instance of an object
it refers to the spawning script:
using System.Collections;
using System.Collections.Generic;
using Photon.Pun;
using UnityEngine;
using Cinemachine;
public class PlayerSpawner : MonoBehaviour
{
[SerializeField] private GameObject playerPrefab = null;
[SerializeField] private CinemachineFreeLook playerCamera = null;
private void Start()
{
//spawn player
var player = PhotonNetwork.Instantiate(playerPrefab.name, Vector3.zero, Quaternion.identity);
//connect Cinemachine
playerCamera.Follow = player.transform;
playerCamera.LookAt = player.transform;
}
}