Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraController : MonoBehaviour
- {
- public PlayerController player;
- public bool isFollowing;
- public float xOffset;
- public float yOffset;
- // Start is called before the first frame update
- void Start()
- {
- player = FindObjectOfType<PlayerController>();
- isFollowing = true;
- }
- // Update is called once per frame
- void Update()
- {
- if (isFollowing)
- {
- transform.position = new Vector3(player.transform.position.x + xOffset, player.transform.position.y + yOffset, transform.position.z);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement