Add scene transitions, lose sanity points
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam.Assets.Scripts
|
||||
{
|
||||
@@ -9,15 +10,13 @@ namespace Scampz.GameJam.Assets.Scripts
|
||||
|
||||
private void OnTriggerEnter(Collider collider)
|
||||
{
|
||||
var allCamerasInCurrentScene = FindObjectsOfType<Camera>();
|
||||
foreach (var sceneCamera in allCamerasInCurrentScene)
|
||||
sceneCamera.enabled = false;
|
||||
|
||||
if (collider.CompareTag("Player"))
|
||||
{
|
||||
foreach (var camera in cameras)
|
||||
camera.enabled = true;
|
||||
}
|
||||
StartCoroutine(ActivateCameras());
|
||||
}
|
||||
|
||||
private IEnumerator ActivateCameras()
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,27 +4,16 @@ namespace Scampz.GameJam
|
||||
{
|
||||
public class CameraFollow : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Transform targetObject;
|
||||
[SerializeField]
|
||||
private Vector3 cameraOffset;
|
||||
[SerializeField]
|
||||
private float smoothFactor = 0.5f;
|
||||
[SerializeField]
|
||||
private bool lookAtTarget = false;
|
||||
[SerializeField]
|
||||
private float _cameraYPosition = 45f;
|
||||
|
||||
private void Start()
|
||||
private void FixedUpdate()
|
||||
{
|
||||
transform.position = targetObject.transform.position - cameraOffset;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
var lockedInYPosition = new Vector3(targetObject.transform.position.x - cameraOffset.x, _cameraYPosition, targetObject.transform.position.z - cameraOffset.z);
|
||||
var player = GameObject.FindGameObjectWithTag("Player");
|
||||
var lockedInYPosition = new Vector3(player.transform.position.x - cameraOffset.x, _cameraYPosition, player.transform.position.z - cameraOffset.z);
|
||||
transform.position = lockedInYPosition;
|
||||
transform.LookAt(transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user