I currently have a script for the camera to follow players around.
using UnityEngine;
using Photon.Pun;
public class PlayerFollowCam : MonoBehaviour
{
public Transform target;
public Vector3 offset;
[Range(1, 10)]
public float smoothingfactor;
private PhotonView view;
public void Start()
{
}
private void FixedUpdate()
{
if (!target) return;
if(gameObject.activeSelf) { SmoothCameraPanning(); }
}
void SmoothCameraPanning()
{
Vector3 CameraTarget = target.position + offset;
Vector3 CameraPosition = Vector3.Lerp(transform.position, CameraTarget, smoothingfactor * Time.fixedDeltaTime);
transform.position = CameraPosition;
}
}
It’s currently tied to the main camera.
Currently, player objects are instantiated by the networkrunnerhandler. It clones a player prefab. I obviously want the camera to only follow your player on screen.
When I add the cloned players transform to the script, it does not work at all.
Thanks for reading.