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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Rydrako · Oct 31, 2012 at 12:29 AM · triggerapplicationitweenpath

Why does my trigger work in the editor but not in the .exe?

Hello, I have this really weird problem with my game. So I have this game object, the boss of the level, that instantiates an object (access card) with a trigger that sets a variable to true for another trigger object (Show Map). With it's variable set to true it calls an iTween Path function and ends the level.

This all works when I'm testing the game in the editor but if I run it in as an .exe it works until I trigger the access card and the Show Map trigger will do absolutely nothing and it is impossible to go to the next level.

Here is the code for the access card object if it would help you:

 using UnityEngine;
 using System.Collections;
 
 public class AccessCard : MonoBehaviour {
 
     // Use this for initialization
     public int up = 8;
     public int down = 2;
     
     void Start () 
     {
             iTween.MoveTo(gameObject, iTween.Hash("y",up,"time",0.5));
             iTween.MoveTo(gameObject, iTween.Hash("y",down,"time",3,"delay",0.5));
     }
     
     // Update is called once per frame
     void Update () 
     {
             shield1 = GameObject.Find("Shield1");
             shield2 = GameObject.Find("Shield2");
             shield3 = GameObject.Find("Shield3");
         
             transform.Rotate(0,15,0);
             if(shield1.transform.position.y == 112)
             {
                     Destroy(shield1.gameObject);
             }
             if(shield2.transform.position.y == 112)
             {
                     Destroy(shield2.gameObject);
             }
             if(shield3.transform.position.y == 112)
             {
                     Destroy(shield3.gameObject);
             }
     }
     
     void OnTriggerEnter (Collider collider)
     {
         if(collider.tag == "Player")
         {
             ShowMap1.canTrig = true;
             RemoveShields();
             Destroy(gameObject);
         }
     }
     
     private GameObject shield1;
     private GameObject shield2;
     private GameObject shield3;
     private GameObject bossDoor;
     
     void RemoveShields ()
     {
             shield1 = GameObject.Find("Shield1");
             shield2 = GameObject.Find("Shield2");
             shield3 = GameObject.Find("Shield3");
             bossDoor = GameObject.Find("BossDoor");
         
             iTween.MoveTo(shield1.gameObject, iTween.Hash("y",112));
             iTween.MoveTo(shield2.gameObject, iTween.Hash("y",112));
             iTween.MoveTo(shield3.gameObject, iTween.Hash("y",112));
             Destroy(bossDoor.gameObject);
     }
 }

And the Show Map trigger calling the iTween Path:

 using UnityEngine;
 using System.Collections;
 
 public class ShowMap1 : MonoBehaviour {
 
 public int time = 5;
 private bool playClip = false;
 private bool trig = false;
 public static bool canTrig = false;
 public GameObject cam;
 public GameObject planet;
 private bool denied = false;
 public bool secret = false;
 
 void Update ()
 {
         if(playClip)
         {
                 iTween.MoveTo(cam, iTween.Hash("path" , iTweenPath.GetPath("camPath"), "time", time));
                 playClip = false;
         }
         if(trig)
         {
                 cam.transform.LookAt(planet.transform.position);
         }
         if (cam.transform.position == new Vector3(0,-457.5542f,599.0647f))
         {
                 Application.LoadLevel(7);
         }
 }
 
 void OnTriggerEnter (Collider collider)
 {
     cam = GameObject.Find("Main Camera");
         
         if(collider.tag == "Player")
         {
                 if(secret)
                 {
                         Destroy(cam.GetComponent("SmoothFollow"));
                         playClip = true;
                         trig = true;
                 }
                 else
                 {
                         if(canTrig)
                         {
                                 Destroy(cam.GetComponent("SmoothFollow"));
                                 playClip = true;
                                 trig = true;
                         }
                         else
                         {
                                 denied = true;
                         }
                 }
         }
 }
 
 void OnTriggerExit ()
 {
         if(denied)
         {
                 denied = false;
         }
 }
 
 void OnGUI ()
 {
         if(denied)
         {
                 GUI.Box(new Rect(Screen.width/2-100,Screen.height/2-15,200,30), "Access Denied");
         }
 }
 }
 

Also I normally program in JavaScript not C# these are my only C# scripts so I could get the iTweenPath to work because iTweenPath isn't compatible with JavaScript last time I tried.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Rydrako · Nov 02, 2012 at 12:45 PM

Okay Here is what I found out. Computers can be stupid sometimes compiling code. The place were I had the

 if(canTrig)

I had to change that to

 if(canTrig==true)

And then it all works!

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

9 People are following this question.

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

Related Questions

OnTriggerEnter Does Not Recognize Collider That Is Moved By iTween 0 Answers

How to make an Application.quit on trigger? 3 Answers

ITweenPath Trigger 0 Answers

Loading player location in a scene 2 Answers

Can't click gameobject when over another trigger? 1 Answer


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