Forum begins after the advertisement:
-
::My character just jumping to another scene after i start the game
Here is the CameraManger.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class CameraManager : MonoBehaviour
{
[SerializeField] CinemachineVirtualCamera[] virtualCameras;
private CinemachineVirtualCamera currentCamera;
private CinemachineFramingTransposer currentTransposer;
public static CameraManager Instance { get; private set; }
private void Awake()
{
if (Instance == null)
{
Instance = this;
}
for (int i = 0; i < virtualCameras.Length; i++)
{
if (virtualCameras[i].enabled)
{
currentCamera = virtualCameras[i];
currentTransposer = currentCamera.GetCinemachineComponent<CinemachineFramingTransposer>();
}
}
}
private void Start()
{
for (int i = 0; i < virtualCameras.Length; i++)
{
virtualCameras[i].Follow = PlayerController.Instance.transform;
}
}
public void SwapCamera(CinemachineVirtualCamera _camera)
{
currentCamera.enabled = false;
currentCamera = _camera;
currentCamera.enabled = true;
}
}
Here is the CameraTrigger.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class CameraTrigger : MonoBehaviour
{
[SerializeField] private CinemachineVirtualCamera newCamera;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnTriggerEnter2D(Collider2D _other)
{
if(_other.CompareTag("Player"))
{
CameraManager.Instance.SwapCamera(newCamera);
}
}
}
::What happens when you disable both scripts? Does the issue still happen?
Try disabling different scripts on the Scene until the issue resolves, then you will know which is the script causing the problem. Once you find that, post the script here again.