So im trying to make a simple room transition by having the camera basically flip into a new area after the "player" hits the collider.
here is the errors:
NullReferenceException: Object reference not set to an instance of an object RoomMove.Start () (at Assets/Scripts/RoomMove.cs:14)
NullReferenceException: Object reference not set to an instance of an object RoomMove.OnTriggerEnter2D (UnityEngine.Collider2D player) (at Assets/Scripts/RoomMove.cs:26)
here is the code:
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RoomMove : MonoBehaviour
{
public Vector2 cameraChangeMax;
public Vector2 cameraChangeMin;
public Vector3 playerChange;
private CameraMovement cam;
// Start is called before the first frame update
void Start()
{
cam = Camera.main.GetComponent<CameraMovement>();
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D player)
{
if (player.CompareTag("Player"))
{
cam.minPosition += cameraChangeMin;
cam.maxPosition += cameraChangeMax;
player.transform.position += playerChange;
}
}
}