You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

45 lines
1.2 KiB

using UnityEngine;
using System.Collections;
public class script : MonoBehaviour {
public GameObject player;
private thirdPersonController playerController;
public float minDistance;
private float maxDistance;
private bool colliding = false;
private float curCameraX;
private float curCameraY;
private Vector3 curPosition;
// Use this for initialization
void Start () {
playerController = player.GetComponent<thirdPersonController> ();
maxDistance = playerController.cameraDistance;
}
// Update is called once per frame
void Update () {
if (!colliding && playerController.cameraDistance < maxDistance && (curCameraX != playerController.cameraX ||curCameraY != playerController.cameraY || player.transform.position != curPosition))
playerController.cameraDistance += 0.2f;
}
void OnTriggerStay(Collider other) {
colliding = true;
Debug.Log ("cameraCollider");
if (playerController.cameraDistance > minDistance) {
playerController.cameraDistance -= 0.2f;
curCameraX = playerController.cameraX;
curCameraY = playerController.cameraY;
curPosition = player.transform.position;
}
}
void OnTriggerExit(Collider other) {
colliding = false;
}
}