::When I preview my game this error comes from console:
NullReferenceException: Object reference not set to an instance of an object
SceneTransition.Start () (at Assets/SceneTransition.cs:27)
When I touch my Scene Transition, it does not transition me into my next scene, instead the player walks in one direction and the console give me this error.
NullReferenceException: Object reference not set to an instance of an object
SceneTransition.OnTriggerEnter2D (UnityEngine.Collider2D _other) (at Assets/SceneTransition.cs:40)
This my scene transition code:
<code>using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class SceneTransition : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] private string transitionTo;
[SerializeField] private Transform startPoint;
[SerializeField] private Vector2 exitDirection;
[SerializeField] private float exitTime;
private void Start()
{
if(GameManager.Instance.transitionedFromScene == transitionTo)
{
PlayerController.Instance.transform.position = startPoint.position;
StartCoroutine(PlayerController.Instance.WalkIntoNewScene(exitDirection, exitTime));
}
StartCoroutine(UIManager.Instance.sceneFader.Fade(SceneFader.FadeDirection.Out));
}
private void OnTriggerEnter2D(Collider2D _other)
{
if(_other.CompareTag("Player"))
{
GameManager.Instance.transitionedFromScene = SceneManager.GetActiveScene().name;
PlayerController.Instance.pState.cutscene = true;
PlayerController.Instance.pState.invincible = true;
StartCoroutine(UIManager.Instance.sceneFader.FadeAndLoadScene(SceneFader.FadeDirection.In, transitionTo));
}
}
}</code>
View post on imgur.com