Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by sgPwnZone · Jul 20, 2013 at 08:56 PM · javascripterrorbuild-errorexport

Major errors on Build/export of game (CODING HELP NEEDED)

I've run into another, sadly far more complicated problem. So i've been working on a small indie horror game, and I've been periodically exporting and uploading a web version of my game to show my friends and colleagues my progress. This has all been great until very recently something has gone awfully wrong in the scripting. Along the way, I have always been getting a few warning or a error or two, but it will still let me play it in the unity editor and export it. Very recently, I was experimenting with a zombie enemy in my game, and It't hard to explain, but all of a sudden when I export (or "build it or whatever") my game pretty much all of my scripted objects vanish in the game, and I have a flashlight that you can pickup and then turn on and off, but now you start out with the flashlight for some reason, and everything is just totally screwed. I've been trying every thing I know and I just can't fix it.

I suspect it has something to do with the whole #pragma strict thing. I don't really know exactly know what #pragma strict function does, but I know that it has something to do with dynamic coding and every time I make a new JavaScript that It always adds it, and I always take it away. If I add it to pretty much any off my functions then it causes errors like so-

Assets/Scripts/ZombieKill.js(32,15): BCE0019: 'enabled' is not a member of 'Object'.

....

Here is one of my scripts for example, I don't know if this will help. This is the "zombie kill" script that makes it to where if my player walks into the zombie's Box Collider, then a red texture and text pops up saying "You Died" and then you are sent back to the main menu.

 var Noise:AudioClip;
 private var ydtexture;
 private var ydtext;
 private var look;
 private var notei;
 private var crosshair;
 private var pause;
 private var icon;
 
 function Start()
 { 
 ydtexture = gameObject.Find("YouDied").GetComponent("GUITextur e");
 ydtexture.enabled = false;
 ydtext = gameObject.Find("ydtext").GetComponent("GUIText");
 ydtext.enabled = false;
 look = gameObject.Find("Player").GetComponent("RBFPSContr ollerLogic");
 crosshair = gameObject.Find("Player").GetComponent("AdvancedCr osshairSG");
 icon = gameObject.Find("Player").GetComponent("chEnhancer ");
 //crosshair.enabled = true;
 notei = gameObject.Find("NOTEgui").GetComponent("ShowPaper ");
 notei.enabled = true;
 pause = gameObject.Find("Player").GetComponent("PauseMenu" );
 pause.enabled = true;
 }
 
 function OnTriggerEnter (other : Collider) {
 if(other.tag == "Player" && this.enabled) {
 audio.PlayOneShot (Noise);
 ydtexture.enabled = true;
 ydtext.enabled = true;
 look.enabled = false;
 icon.enabled = false;
 crosshair.enabled = false;
 notei.enabled = true; 
 pause.enabled = false;
 yield WaitForSeconds (4);
 Application.LoadLevel(0);
 
 
 }
 }



So, I was hoping that maybe you know a thing or two about scripting and you could help get me out of this Awful predicament. Thank you so much for your time.

Email- sammygray123@gmail.com

Sincerly, Sam

Comment
Add comment · Show 1
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 Eric5h5 · Jul 20, 2013 at 09:00 PM 0
Share

Use the code format button whenever you post code.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Eric5h5 · Jul 20, 2013 at 08:58 PM

Never use the Array class (use built-in arrays or generic Lists instead), and always define the type of all variables, either explicitly, or implicitly by declaring a value. e.g., "var x;" is wrong, "var x = 5;" is fine, "var x : int;" is fine. Also never use quotes in GetComponent.

Comment
Add comment · Show 7 · 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
avatar image sgPwnZone · Jul 20, 2013 at 09:26 PM 0
Share

Could you explain the array part a bit more. I'm sorry i'm just very new, and I'm trying very hard to learn. By the way I went and edited the code part of the post like you said so it's easier to read. And what if the variables i'm using are not intriguers. How would I fix this problem all together, I know its a hassle but if you could post I fixed code It would help me SO $$anonymous$$UCH, I just need one working example to base my other codes off of so everything does screw over when I export it.

avatar image Eric5h5 · Jul 20, 2013 at 09:38 PM 0
Share
 var foo : Array; // wrong
 var foo : int[]; // good
 var foo : List.< int >; // good

 var foo = GetComponent("GUITexture"); // wrong
 var foo = GetComponent(GUITexture); // right

what if the variables i'm using are not intriguers

Use whatever type is appropriate.

avatar image sgPwnZone · Jul 20, 2013 at 09:51 PM 0
Share

so, Since the variables are scripts, would it be var look : $$anonymous$$onoScript; ?? and would the GUIs be var ydtexture : GUITexture; ??

also, should the variables be written as var, private var, or public var

avatar image Eric5h5 · Jul 20, 2013 at 09:58 PM 0
Share

Since the variables are scripts, would it be var look : $$anonymous$$onoScript; ??

No, the type is the name of the script.

 var look : RBFPSControllerLogic;

Variables should be private unless they need to be accessed from other scripts. "var" and "public var" are the same thing.

avatar image sgPwnZone · Jul 22, 2013 at 12:38 AM 0
Share

Ok, so I went and did everything you said like defining the variables and taking the quotation marks away, BUT IT STILL DOESN'T WOR$$anonymous$$ :( .... like I said before, it works just fine in the editor, and I don't get any errors, BUT when I export it to a web-build or standalone build (i've tried both regular export AND development build) It still screws up, and some of my scripted stuff disappears forsome reason.

Show more comments

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

16 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

Related Questions

Collisions arn't working properly 0 Answers

Help !! MIssing Semi colon in my coding 1 Answer

Ball jumping mechanic, scrip errors. 1 Answer

Why am I getting this error repeatedly? 2 Answers

simple error messages, need help with them. 0 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