// Update is called once per frame override public void Update() { CameraVO vo = GameVO.Instance.camera; Transform cameraTransform = vo.cameraTransform; Transform lookAtTransform = vo.lookAtTransform; cameraTransform.localPosition = new Vector3(lookAtTransform.position.x, lookAtTransform.position.y); }
// Update is called once per frame override public void Update() { CameraVO vo = GameVO.Instance.camera; Transform cameraTransform = vo.cameraTransform; Transform lookAtTransform = vo.lookAtTransform; //是否需要移动的标志位 bool moveFlag = false; float x = cameraTransform.position.x; float y = cameraTransform.position.y; //如果角色不超过某个区域就不移动 //超出可移动范围左边 if (lookAtTransform.position.x < cameraTransform.position.x - vo.cameraSize.x * (0.5f - rangeLeft)) { moveFlag = true; x = lookAtTransform.position.x + vo.cameraSize.x * (0.5f - rangeLeft); } //超出可移动范围右边 if (lookAtTransform.position.x > cameraTransform.position.x + vo.cameraSize.x * (0.5f - rangeRight)) { moveFlag = true; x = lookAtTransform.position.x - vo.cameraSize.x * (0.5f - rangeRight); } //超出可移动范围下边 if (lookAtTransform.position.y < cameraTransform.position.y - vo.cameraSize.y * (0.5f - rangeDown)) { moveFlag = true; y = lookAtTransform.position.y + vo.cameraSize.y * (0.5f - rangeDown); } //超出可移动范围上边 if (lookAtTransform.position.y > cameraTransform.position.y + vo.cameraSize.y * (0.5f - rangeUp)) { moveFlag = true; y = lookAtTransform.position.y - vo.cameraSize.y * (0.5f - rangeUp); } this.moveFlag = moveFlag; this.moveX = x; this.moveY = y; }
// Use this for initialization void Start() { vo = GameVO.Instance.camera; }
public LookAtFront() { vo = GameVO.Instance.camera; cameraTransform = vo.cameraTransform; lookAtTransform = vo.lookAtTransform; }