34 lines
905 B
C#
34 lines
905 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
/*
|
||
|
Sends the necessary Requests to the CameraController saying "Hi i want to be rendered"
|
||
|
The CameraController then obliges like the nice Guy he is :)
|
||
|
*/
|
||
|
public class ReactiveCamera : MonoBehaviour
|
||
|
{
|
||
|
|
||
|
[SerializeField] private Camera cam;
|
||
|
[SerializeField] private EdgeCollider2D col;
|
||
|
Rigidbody2D rb;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
col = GetComponent<EdgeCollider2D>();
|
||
|
rb = GetComponent<Rigidbody2D>();
|
||
|
cam = GetComponentInChildren<Camera>();
|
||
|
rb.isKinematic = true;
|
||
|
CameraController.Register(cam);
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void OnTriggerEnter2D(Collider2D other)
|
||
|
{
|
||
|
if(other.gameObject.CompareTag("Player"))
|
||
|
{
|
||
|
if(CameraController.CurrentCamera() != cam) CameraController.ActivateCamera(cam);
|
||
|
}
|
||
|
}
|
||
|
}
|