Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- [RequireComponent(typeof(BoxCollider))]
- [ExecuteInEditMode]
- public class PerZoneCamera : MonoBehaviour
- {
- public string ZoneName;
- [Space(10)]
- public FirstPersonAIO fpsScript;
- public ThirdPerson tdsScript;
- public GameObject FPS, TDS;
- public BoxCollider colision;
- [Space(10)]
- public Color Zonecolor;
- [Space(10)]
- public Vector3 ZoneSize;
- public string TagName;
- public bool isEnter;
- public Transform originalCamera;
- public Transform LookOBJ;
- public CharacterController CCTDS;
- private void Start()
- {
- colision = GetComponent <BoxCollider>();
- }
- private void Update()
- {
- this.transform.name = ZoneName;
- colision.size = ZoneSize;
- colision.isTrigger = true;
- }
- private void OnDrawGizmos()
- {
- Gizmos.color = Zonecolor;
- Gizmos.DrawCube(transform.position, ZoneSize);
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.tag == TagName)
- {
- isEnter = true;
- Invoke("ActivarTerceraPersona", 0.3f);
- }
- }
- private void OnTriggerExit(Collider other)
- {
- if (other.tag == TagName)
- {
- isEnter = false;
- tdsScript.camera = originalCamera;
- Invoke("UsarPrimeraPersona", 1f);
- }
- }
- void ActivarTerceraPersona()
- {
- FPS.SetActive(false);
- TDS.SetActive(true);
- TDS.transform.position = FPS.transform.position;
- fpsScript.enabled = false;
- tdsScript.enabled = true;
- CCTDS.enabled = true;
- }
- void UsarPrimeraPersona()
- {
- FPS.SetActive(true);
- TDS.SetActive(false);
- FPS.transform.position = TDS.transform.position;
- tdsScript.enabled = false;
- fpsScript.enabled = true;
- CCTDS.enabled = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement