Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
1
Question by SweetInsanityArts · Feb 05, 2020 at 10:25 AM · buildscript.script errorbuilding

Some scripts stop working on build but work in editor?

I'm working on my first ever project that has to be handed in next week and it was all running smoothly in the editor but when I export the game, some of the scripts don't seem to work.

As far as I can tell, the scripts in questions are the ones that control damage & healing. They're split into 3 different scripts.

collect.cs

 public class collect : MonoBehaviour
 {
     public int Mana;
     public int Gesundheit;
     public AudioSource Eat;
     public AudioSource Squeak;
 
     private void OnTriggerEnter2D(Collider2D other)
     {
         GameObject.Find("GAME").GetComponent<GAME>().gesammelt(Mana, Gesundheit);
         if (gameObject.tag=="heal")
         {
             Eat.Play();
             gameObject.SetActive(false);
         }
 
         if (gameObject.tag == "thorns")
         {
             Squeak.Play();
         }
 
     }
 }

values.cs

 [CreateAssetMenu(fileName = "Werte", menuName = "Daten/Speicher/Werte")]
 public class Werte : ScriptableObject, ISerializationCallbackReceiver
 {
   public int Mana = 0;
   public int Gesundheit = 100;
 
   private int DefaultMana = 100;
   private int DefaultGesundheit = 100;
 
   public void OnBeforeSerialize()
   {
     
   }
 
   public void resetvalues()
   {
     Mana = DefaultMana;
     Gesundheit = DefaultGesundheit;
   }
   
   public void OnAfterDeserialize()
   {
     Mana = DefaultMana;
     Gesundheit = DefaultGesundheit;
   }
 }

and the GAME.cs to manage it all.

 public class GAME : MonoBehaviour
 {
     //public Text Punkteanzeige;
     public Werte Spielstand;
     public GameObject rat;
     public GameObject explosion;
     public RectTransform barFillRT;
     private Vector3 barFill;
    
     void Start()
     {
         barFill = barFillRT.localScale;
 
     }
 
     public void gesammelt(int p, int g)
     {
         Spielstand.Mana += p;
         Spielstand.Gesundheit += g;
         Spielstand.Gesundheit = Mathf.Clamp(Spielstand.Gesundheit,0, 100);
         barFill.x = Spielstand.Gesundheit/100f;
         barFillRT.localScale = barFill;
         if (Spielstand.Gesundheit<=0)
         {
             GameObject exp=Instantiate(explosion, transform.position,transform.rotation);
             exp.transform.position = rat.transform.position;
             rat.SetActive(false);
             StartCoroutine("RestartLevel");
         }
         
     }
     
     
     IEnumerator RestartLevel() {
         yield return new WaitForSeconds(3f);
         Spielstand.resetvalues();
         SceneManager.LoadScene(SceneManager.GetActiveScene().name);
     }
     
     }

Anyone know why those aren't exported/don't work in the exported game? I checked the console but it isnt giving me any errors.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JPhilipp · Feb 05, 2020 at 11:34 AM 0
Share

@SweetInsanityArts How do they stop working, they are just ignored? Throw errors? What happens? Also, for what platform are you building, is it PC or Android or...?

avatar image SweetInsanityArts JPhilipp · Feb 05, 2020 at 12:15 PM 0
Share

Building for PC

They are ignored, I'm guessing? I run into the colliders that are supposed to trigger the script and the character slows down a bit so the collider is definitely still there but it doesnt take any damage, health bar doesnt go down, sound isnt played.

Is there a way to see errors while playing the actual game like the console in the Unity editor?

avatar image JPhilipp SweetInsanityArts · Feb 05, 2020 at 12:20 PM 0
Share

@SweetInsanityArts Here's some info on that. Viel Glück.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tormentoarmagedoom · Feb 05, 2020 at 12:20 PM

Hello. Scripts seems correct, the problem is not here. You should know first what is happening exactly. As @JPhilipp says, What is happening? Do something to know what parts of the code are beeing called, like create a text in a canvas to "say" and "check" when the code reach some parts of the code, so you can know for example if the trigger part code is beeing called while the game is built and running. MAybe is a collider-detection problem. Are the objects moving very fast? Then Change Collision detection to Continous from the inspector.

Good luck"

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

226 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how do i add script folder to final build 0 Answers

Is it possible to output different builds which share the same Data folder? 0 Answers

Massive File Header Build Size 1 Answer

The referenced script on this Behaviour is missing - on any new script 0 Answers

UnityEditor.Animations API in a build 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges