CameraController and ReactiveCamera + Prefab for CameraWithTrigger and
Frank added
This commit is contained in:
33
Assets/AssetsFORELLE/Script/ReactiveCamera.cs
Normal file
33
Assets/AssetsFORELLE/Script/ReactiveCamera.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user