Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //From Unity Learn
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class FollowPlayer : MonoBehaviour
- {
- public GameObject player;
- [SerializeField] Vector3 offset = new Vector3(0, 5, -10);
- void LateUpdate()
- {
- transform.position = player.transform.position + offset;
- }
- }
- //From Ferrone H. Learning C# by Developing Games with Unity...7ed 2022
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraBehaviour : MonoBehaviour
- {
- public Vector3 camOffset = new Vector3(0, 1.2f, -2.6f);
- private Transform target;
- void Start()
- {
- target = GameObject.Find("Player").transform;
- }
- void LateUpdate()
- {
- transform.position = target.TransformPoint(camOffset);
- transform.LookAt(target);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement