Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class PlayerCamera : MonoBehaviour
- {
- Transform tx;
- [SerializeField] Transform tx_player;
- [SerializeField] Vector3 offset = new Vector3(0, 1, 0);
- [SerializeField] float smoothTime = 0.8f;
- private Vector3 Velocity;
- private Vector3 offsetsubstract;
- private Vector3 current;
- void Start()
- => tx = transform;
- void Update()
- {
- current = tx.position;
- current -= offsetsubstract;
- tx.position = offset + Vector3.
- SmoothDamp(current, tx_player.position, ref Velocity, smoothTime);
- offsetsubstract = offset;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment