1234567891011121314151617181920212223242526272829303132333435 |
- using System.Collections;
- using System.Collections.Generic;
- using Unity.VisualScripting;
- using UnityEngine;
- public class cameraRPG : MonoBehaviour
- {
- public static cameraRPG instance;
-
- public Transform focus;
- public float smoothTime = 2;
- public Vector3 offset;
- void Awake()
- {
- instance = this;
-
- }
- public void SetTarget(Transform target){
- focus = target;
- //offset = focus.position - transform.position;
- }
- public bool isPaused =false;
- void Update()
- {
- if(focus == null){return;}
- if(isPaused){return;}
- transform.position = Vector3.Lerp(transform.position, focus.position - offset, Time.deltaTime * smoothTime);
- }
- public void Teleport(Vector3 newLocation){
- transform.position = newLocation - offset;
- }
- }
|