Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 BenDurch · May 03, 2014 at 03:03 AM · buildbuild-errorlevellevelsleveling

frustrating building problem

i have made a script that is used to navigate levels, it works perfectly in unity, but when i build the project the script does not work! i can't seem to find the problem. could anybody tell me what is going on?

here is the code.

 using UnityEngine;
 using System.Collections;
 
 public class Portal : MonoBehaviour {
     public float number;
     public bool hasEnoughChips;
     public bool hasEnoughCodes;
     public bool hasEnoughFloppys;
     public bool Chip;
     public bool Code;
     public bool Flop;
     public bool end;
     public GameObject Player;
     void Start () {
         Player = GameObject.FindGameObjectWithTag ("pow");
     }
     void Update(){
         float distance = Vector3.Distance(Player.transform.position, transform.position);
         int cur_level = Application.loadedLevel;
         if (Chip == true) {
             if (Resources.control.Chip >= number) {
                                 hasEnoughChips = true;
             }
                 } 
         if (Code == true) {
                         if (Resources.control.Code >= number) {
                                 hasEnoughCodes = true;
                         }
 
                 }
         if (Flop == true) {
             if (Resources.control.Flop >= number) {
                                 hasEnoughFloppys = true;
             }
                 }
         if (distance<3){
             if (Chip == true){
                 if(hasEnoughChips == true){
                     Application.LoadLevel(cur_level + 1);
                 }else{
                     Application.LoadLevel(0);
                     Resources.control.Save();
                 }
             }
             if (Code == true){
                 if(hasEnoughCodes == true){
                     Application.LoadLevel(cur_level + 1);
                 }else{
                     Application.LoadLevel(0);
                     Resources.control.Save();
                 }
             }
             if (Flop == true){
                 if(hasEnoughFloppys == true){
                     Application.LoadLevel(cur_level + 1);
                 }else{
                     Application.LoadLevel(0);
                     Resources.control.Save();
                 }
             }
             if (end == true){
                 Application.LoadLevel(0);
             }
         }
     }
 }
Comment
Add comment · Show 7
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 mattyman174 · May 03, 2014 at 03:12 AM 0
Share

Did you add the Scenes to the Build in the Build Settings?

avatar image BenDurch · May 03, 2014 at 05:29 PM 0
Share

yes there is no problem with that.

avatar image 0V3RR1D3 · May 03, 2014 at 05:34 PM 0
Share

$$anonymous$$ay seem silly but you dont have the object its set on taged as editor only do you?

avatar image BenDurch 0V3RR1D3 · May 03, 2014 at 07:08 PM 0
Share

what do you mean? that is worded funny

avatar image BenDurch 0V3RR1D3 · May 04, 2014 at 01:29 AM 0
Share

thaT is not it because it works perfectly fine with another script.

avatar image BenDurch · May 04, 2014 at 01:29 AM 0
Share

it is just too weird. i have re written the code multiple times and the same thing happens in the editor, but this script does not seem to work in the built project. i am very lost.

here is the latest version...

using UnityEngine; using System.Collections;

public class Portal : $$anonymous$$onoBehaviour { public float Amount; public float Chips; public float Codes; public float Flops; public bool needsChips; public bool needsCodes; public bool needsFlops; public int nextLevel; public GameObject Player; public float portalSize;

 void Update(){
     float distance = Vector3.Distance(Player.transform.position, transform.position);
     Chips = Resources.control.Chip;
     Codes = Resources.control.Code;
     Flops = Resources.control.Flop;






     if (needsChips == true) {
         if (distance <= portalSize) {

             if (Amount <= Chips) {
                 Application.LoadLevel (nextLevel);
             } else {
                 Application.LoadLevel (0);
             }
         }
     }
     if (needsCodes == true) {
         if (distance <= portalSize) {
             
             if (Amount <= Codes) {
                 Application.LoadLevel (nextLevel);
             } else {
                 Application.LoadLevel (0);
             }
         }
     }
     if (needsFlops == true) {
         if (distance <= portalSize) {
             
             if (Amount <= Flops) {
                 Application.LoadLevel (nextLevel);
             } else {
                 Application.LoadLevel (0);
             }
         }
     }

     }
 void OnDrawGizmosSelected() {
     Gizmos.color = Color.red;
     Gizmos.DrawWireSphere(transform.position, portalSize);
 }

}

avatar image AlucardJay BenDurch · May 04, 2014 at 01:30 AM 1
Share

Please don't post comments as answers. Post comments by clicking the [add new comment] button, a window then open for you to type in. Answer fields are for answers only, as this is a knowledge base.

Here at Unity Answers, Answer means Solution, not Response.

0 Replies

· Add your reply
  • Sort: 

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

23 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

Related Questions

Distribute terrain in zones 3 Answers

Roll a Ball can't pick up game objects in the build? 0 Answers

Mac build closing on start, Windows version works (permissions problem?) 1 Answer

no suitable applciation records were found 1 Answer

Why does my build project can't connect to sqlite database? 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