Forum begins after the advertisement:


[part 5] Player running infinitely off platform

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [part 5] Player running infinitely off platform

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #15482
    reeean
    Level 1
    Participant
    Helpful?
    Up
    0
    ::

    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:

    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));
            }
        }
    }

    View post on imgur.com

    #15498
    reeean
    Level 1
    Participant
    Helpful?
    Up
    0
    ::

    ISSUE RESOLVED

    I UNCHECKED THE SCENEFADER BY ACCIDENT

    P.S I LOVE YOU GUYS, LOVE ME

    #15499
    Terence
    Level 30
    Keymaster
    Helpful?
    Up
    0
    ::

    Love you too reean

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: