Forum begins after the advertisement:


[Part 5] Scene Transition Error

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 5] Scene Transition Error

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #13085
    Ultimate Scripted
    Participant

    so when going back and forth through the scene transitions it gives me this error:

    NullReferenceException: Object reference not set to an instance of an object
    PlayerController.Move () (at Assets/Scripts/PlayerScripts/PlayerController.cs:127)
    PlayerController+<WalkIntoNewScene>d__28.MoveNext () (at Assets/Scripts/PlayerScripts/PlayerController.cs:112)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5879d8d225474494bcffdfe64965038e>:0)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    SceneTransition:Start() (at Assets/Scripts/SceneScripts/SceneTransition.cs:20)

    here is all my scripts this error is attacking.

    View post on imgur.com

    View post on imgur.com

    View post on imgur.com

    #13086
    Terence
    Keymaster

    Hi Ultimate Scripted, thanks for making your post here. Your Imgur images are probably set to private or to prevent embedding, that’s why they are not showing up on the post.

    Can you try re-embedding the images? Or you can paste the codes as text here.

    #13088
    Ultimate Scripted
    Participant

    sorry i was a little confused on how to use imgur and i embedded the links before posting to public.
    ill just repost code pictures here:

    View post on imgur.com

    NullReferenceException: Object reference not set to an instance of an object
    PlayerController.Move () (at Assets/Scripts/PlayerScripts/PlayerController.cs:127)
    PlayerController+<WalkIntoNewScene>d__28.MoveNext () (at Assets/Scripts/PlayerScripts/PlayerController.cs:112)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <5879d8d225474494bcffdfe64965038e>:0)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    SceneTransition:Start() (at Assets/Scripts/SceneScripts/SceneTransition.cs:20)
    #13097
    Terence
    Keymaster

    No problem. I’ve cleaned up your posts. To embed an image, you just need to leave the URL on a separate line like this:

    Your post content
    https://imgur.com/a/0CIbonD

    For your code, I suspect you are missing the following line in Start():

    rb = GetComponent<Rigidbody2D>();

    So when you do rb.velocity, you are essentially doing null.velocity, which is what is causing the error.

    We have a video that explains null references in more detail:

    #13290
    Ultimate Scripted
    Participant

    Okay i am back, i had stopped for finals week in school but thats now over and ive solved the issue, so somewhere in my cameramanager script i was relating to a component, the framingtransposer but it doesnt exist as an actual component in cinemachine or something. when taking away that references the scene transition works! but now i have another problem. i moved onto the part where he adds the vertical transitions and for some reason two things happen, first my player teleports back and forth from both scenes unable to break free but this only happens when the player is coming from a scene thats supposed to be beneath the one its jumping up too, and secondly when dropping down to that very scene it doesnt break and teleport back and forth but it does draw my player directly on the camera so while its there you cant see the player, i will provide a video of both of these things happening.

    #13291
    #13295
    Terence
    Keymaster

    For the infinite teleport, check both the triggers that are involved in teleporting you to the next level. Are there components you’ve added that should not be there?

    If you are unable to find anything amiss, screenshot the Inspectors of both GameObjects and show it to me.

    #13313
    Ultimate Scripted
    Participant

    Nothing seems to be wrong. heres a picture of both my transitions:

    View post on imgur.com

    Oh and i know the exit time and direction for forest room 3 is incorrect i was just testing out different values because the original ones werent working so that why its all zero right now

    #13317
    Terence
    Keymaster

    Is your Start Point for one of the maps inside the Box Collider of one of the Scene Transition objects?

    #13324
    Ultimate Scripted
    Participant

    No it shouldnt be.

    start point

    #13326
    Terence
    Keymaster

    Can you move the start points further away from the collider to see if it fixes the issue? For example, in your first scene, the start point is right above the transition box. Perhaps you can move it onto the platform to the right? So when the Scene starts, your character won’t fall into the trigger right below.

    Let me know if this fixes things.

    #13346
    Ultimate Scripted
    Participant

    Ok so that worked! i can now go from the bottom transition to the top (scene 3 to scene 1) with out it rapidly switching back and forth. but the issue for the player being drawn on the wrong layer is still here. when going from top scene (scene 1) to the bottom one it will still draw it (the player) onto the camera even though the player is there i cant see it. ive also created another problem where i had re-made my boundings box colliders which broke my other transition and now when going into scene one it duplicates the camera stuff over to that scene instead of just switching, it was stupid of me to make the platform of where the player walks into a child of the bounding boxes and i had made that into a prefab when i realized this gave would give me complications it was already to late because i had deleted that prefab and then it destroyed the ground for scene 2 now resulting in these issues. i kinda wanna just restart everything now 😞. but besides me being stupid thanks for the help i very much apreciate it.

    #13347
    Terence
    Keymaster

    Ultimate, glad your issue was resolved. For the layers issue, if you need help fixing it, you can take a video of the issue and I’ll pinpoint some things you can try to resolve it.

    I don’t suggest restarting the project! If you don’t figure out how to fix your issue in this project, it might just reoccur again when you restart the project!

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

Go to Login Page →


Advertisement below: