Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class CameraController : MonoBehaviour {
- public Transform Character;
- private float XThreshold = 3.0f;
- private float YThreshold = 3.0f;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if (Character.position.x > transform.position.x + XThreshold) {
- transform.position = new Vector3(Character.position.x-XThreshold, transform.position.y, transform.position.x);
- } else if (Character.position.x < transform.position.x - XThreshold) {
- transform.position = new Vector3(Character.position.x+XThreshold, transform.position.y, transform.position.x);
- }
- if (Character.position.y > transform.position.y + YThreshold) {
- transform.position = new Vector3(transform.position.x, Character.position.y-YThreshold, transform.position.x);
- } else if (Character.position.y < transform.position.y - XThreshold) {
- transform.position = new Vector3(transform.position.x, Character.position.y+YThreshold, transform.position.x);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment