Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class CameraFollow : MonoBehaviour
- {
- // Start is called before the first frame update
- public GameObject player; // публична променлива/референция към обектът
- private Vector3 offset; // разликата между позицията на камерата и позицията на играча в пространството измерена чрез 3D вектор
- void Start()
- {
- offset = transform.position - player.transform.position;
- }
- void LateUpdate()
- {
- transform.position = player.transform.position + offset;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement