Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Ruby 2D Tutorial - UnassignedReferenceException

Discussion in '2D' started by Gravano, Aug 10, 2019.

  1. Gravano

    Gravano

    Joined:
    Jan 2, 2018
    Posts:
    16
    I've been following this tutorial called Ruby's Adventure for making 2D games, and I've encountered a problem in the section about using projectiles. The tutorial says to create a prefab out of the projectile & to add the projectile script to it. Next it says to add this prefab into a public slot I had created in my Player Controller (RubyController) script, which I did. However, it tells me in game mode that I have an "UnassignedReferenceException: The variable projectilePrefab of RubyController has not been assigned. You probably need to assign the projectilePrefab variable of the RubyController script in the inspector."

    Documentation: https://learn.unity.com/tutorial/wo...66dbedbc2a0021b1bc7c#5c7f8528edbc2a002053b3ed


    Pic 1 (part 1 of script, at the top you can clearly see that the CogBullet prefab is in the appropriate slot)


    Pic 2 (part 2 of script, note the highlighted part is where it takes me when I double click the exception):



    Pic 3 (Error)



    Pic 4 (Prefab CogBullet)



    Pic 5 (Specific part in documentation where hell breaks loose, click the earlier link to the Documentation read full context on that page)



    Thanks, & let me know if anything else is needed to clarify this issue! Btw, in the documentation it states that there will be an error that throws a NullReferenceException & something about the projectile colliding with my player, but these are not the errors I'm experiencing.
     
  2. Valjuin

    Valjuin

    Joined:
    May 22, 2019
    Posts:
    481
    upload_2019-8-11_0-28-2.png
     
    Last edited: Aug 11, 2019
    diamond01a likes this.
  3. Gravano

    Gravano

    Joined:
    Jan 2, 2018
    Posts:
    16
    Thank you Valjuin. Unfortunately, I ran into another problem shortly after this. I'll post it in a second.