I have an FPS controller and I want to change the camera when it collides with a box collider. I think I did it properly but it didn't work. Here's my code:
using UnityEngine;
using System.Collections;
public class change_camera : MonoBehaviour
{
public Camera Playercamera;
public Camera Topcamera;
void OnCollisionEnter(Collision col)
{
if (col.gameObject.name == "FPSController")
{
Playercamera.enabled = false;
Topcamera.enabled = true;
}
}
}
Thanks in advance.