Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In Player Script
- //keeping original player from previous level and destroying new instance
- private void Awake()
- {
- if (instance == null)
- {
- instance = this;
- }
- else
- {
- Destroy(gameObject);
- }
- }
- void Start()
- {
- //This keeps the player to port over to the new level
- DontDestroyOnLoad(gameObject);
- }
- //get virtual camera to follow the player in the new level
- using Cinemachine;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SceneCamera : MonoBehaviour
- {
- [SerializeField] private CinemachineVirtualCamera cinemachineVirtualCamera;
- void Start()
- {
- //get the camera to follow the player in the new level
- cinemachineVirtualCamera.Follow = NewPlayer.Instance.transform;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement