Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Blank public fields left in script can cause unusual issues

Discussion in 'Scripting' started by Silver100, Jun 13, 2023.

  1. Silver100

    Silver100

    Joined:
    May 4, 2019
    Posts:
    30
    Hi,

    Hope you can help,

    Noticed an unusual issue or may be normal and simply my lack of knowledge. Basically I have a player health script with some dialogue elements attached and access to other levels. The player health script is used through out the game in each scene, same health script, so at times part of the script may not even be relevant to a level. If a level does not require a dialogue and these a blank space in the inspector public field area, I some times get unusual errors like game freezes level changes etc. However having filled this blank field with empty game objects or empty text mesh pro the problem is 100% gone. The condition set for changing level is if player makes contact with an active portal (which happens after so many enemies have been destroyed). I have built the game almost finished just making sure its working as best as it can. Just curious to why this is or if it would be better to generate new player health script customised to each scene? Any ideas?
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,742
    Show your code.
     
  3. Silver100

    Silver100

    Joined:
    May 4, 2019
    Posts:
    30
    Please Ignore Just checked through realised I have duplicate scene change should be fine now all good.