Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Cinemachine;
- using UnityEngine;
- public class ChangeCameraSettingsRuntime : PlayerCameras
- {
- [Header("Kling Rigs Attributes")]
- [SerializeField] private CinemachineFreeLook.Orbit newTopKling;
- [SerializeField] private CinemachineFreeLook.Orbit newMidKling;
- [SerializeField] private CinemachineFreeLook.Orbit newBottomKling;
- [Header("Spark Rigs Attributes")]
- [SerializeField] private CinemachineFreeLook.Orbit newTopSpark;
- [SerializeField] private CinemachineFreeLook.Orbit newMidSpark;
- [SerializeField] private CinemachineFreeLook.Orbit newBottomSpark;
- [Header("")]
- [SerializeField] private bool isResettingToDefault;
- private protected override void Awake()
- {
- }
- private void OnTriggerEnter(Collider other)
- {
- bool isKling = other.gameObject.layer == LayerIDs.PlayerMetal;
- bool isSpark = other.gameObject.layer == LayerIDs.PlayerBolt;
- if (!isKling && !isSpark)
- {
- return;
- }
- if (isKling)
- {
- if(isResettingToDefault)
- {
- ResetOrbitsToDefault(true);
- return;
- }
- secondCameraKling.m_Orbits[0] = newTopKling;
- secondCameraKling.m_Orbits[1] = newMidKling;
- secondCameraKling.m_Orbits[2] = newBottomKling;
- ChangeKlingOrbits();
- }
- if (isSpark)
- {
- if(isResettingToDefault)
- {
- ResetOrbitsToDefault(false);
- return;
- }
- secondCameraSpark.m_Orbits[0] = newTopSpark;
- secondCameraSpark.m_Orbits[1] = newMidSpark;
- secondCameraSpark.m_Orbits[2] = newBottomSpark;
- ChangeSparkOrbits();
- }
- }
- private void ChangeKlingOrbits()
- {
- secondCameraKling.m_Priority = 11;
- FreeLookKling.m_Priority = 10;
- }
- private void ChangeSparkOrbits()
- {
- secondCameraSpark.m_Priority = 11;
- FreeLookSpark.m_Priority = 10;
- }
- private void ResetOrbitsToDefault(bool isKling)
- {
- if (isKling)
- {
- secondCameraKling.m_Priority = 10;
- FreeLookKling.m_Priority = 11;
- }
- else
- {
- secondCameraSpark.m_Priority = 10;
- FreeLookSpark.m_Priority = 11;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement