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 Raul 2 · Mar 02, 2011 at 02:03 AM · transformmoveversioncompile

Problem When Compiling Program!

Hello I am having problems when compiling this project. Upon start it should move the "pieces" into place using this code:

    playerOne.transform.position.x = waypoints1[playerOnePoints][0];
playerOne.transform.position.z = waypoints1[playerOnePoints][1];
playerTwo.transform.position.x = waypoints2[playerTwoPoints][0];
playerTwo.transform.position.z = waypoints2[playerTwoPoints][1];

However when i compiled it and ran it, it did not place the transforms at the desired location nor any location. Also the checking for completed questions does work in the editor but not in the compiled version. Here is a link to the project if you wish to compile it and test it in the editor yourself: http://www.mediafire.com/?q475p9gtfab0vpo I appreciate any help or suggestions.

var speed : float = 50.0; var move : int = 0; var currentPlayer : int = 1; var players: int = 2; var playerOne : Transform; var playerTwo : Transform; var playerOnePoints : int = 0; var playerTwoPoints : int = 0; var finalScore : int = 0; var questionAmount : float = 1.0; var questions : Array; var currentQuestion : int = 0; var questionCheck : int = 0; var n : int = 0; var q : int = 0; var timerPerQuestion : int = 3000; var questionAllUsed : boolean = false; var winnerBanner : boolean = false; var lastQuestionDone : boolean = false; var keepGoing : boolean = true; var numOfQuestions : int = 0; var correctA : boolean = false; var delay : float = 3.0; var done : float = 0.0; var waypoints1 : Array; var waypoints2 : Array; var customSkin : GUISkin; //Textures var questionBoard : Texture2D; var continueButton : Texture2D; var goldStar : Texture2D; var correct : Texture2D; var incorrect : Texture2D; var mainMenu : Texture2D; var startGameButton : Texture2D; var quitGameButton : Texture2D;

var initialButton : boolean = true; var waitTimer : int = 0; var waitTimerActive : boolean = false; var answerMark : int = 0; var continueCorrectButton : boolean = false; var continueIncorrectButton : boolean = false; var winner : boolean = false; var playerOneWinner : Texture2D; var playerTwoWinner : Texture2D; var TieWinner : Texture2D; var mainMenuButton : Texture2D; var showQuestion : boolean = false; var startGame : boolean = true; var correctSound : AudioClip; var incorrectSound: AudioClip; var spawn1 : Transform; var waypointOne1 : Transform; var waypointOne2 : Transform; var waypointOne3 : Transform; var waypointOne4 : Transform; var waypointOne5 : Transform; var waypointOne6 : Transform; var waypointOne7 : Transform; var waypointOne8 : Transform; var waypointOne9 : Transform; var waypointOne10 : Transform; var waypointOne11 : Transform; var waypointOne12 : Transform; var waypointOne13 : Transform; var waypointOne14 : Transform; var waypointOne15 : Transform; var seperation : boolean = false; var spawn2 : Transform; var waypointTwo1 : Transform; var waypointTwo2 : Transform; var waypointTwo3 : Transform; var waypointTwo4 : Transform; var waypointTwo5 : Transform; var waypointTwo6 : Transform; var waypointTwo7 : Transform; var waypointTwo8 : Transform; var waypointTwo9 : Transform; var waypointTwo10 : Transform; var waypointTwo11 : Transform; var waypointTwo12 : Transform; var waypointTwo13 : Transform; var waypointTwo14 : Transform; var waypointTwo15 : Transform; var correctAnswer : boolean = false; var incorrectAnswer : boolean = false;

var escHit : boolean = false; var scripts :boolean = true; var escTimer : float = 20;

var quizQuestions : int = 0;

function Start () {

currentQuestion = parseInt(Random.Range(0,3)); questions = [ ["question1","answer11","answer12","answer13","answer14","1","0"], ["question2","answer21","answer22","answer23","answer24","2","0"], ["question3","answer31","answer32","answer33","answer34","3","0"], ["question4","answer41","answer42","answer43","answer44","3","0"],
["question5","answer51","answer52","answer53","answer54","3","0"] ]; numOfQuestions = questions.length; Debug.Log(numOfQuestions); //waypoints for player 1 waypoints1 = [ [spawn1.position.x,spawn1.position.z,"0"], [waypointOne1.position.x,waypointOne1.position.z,"1"], [waypointOne2.position.x,waypointOne2.position.z,"2"], [waypointOne3.position.x,waypointOne3.position.z,"3"], [waypointOne4.position.x,waypointOne4.position.z,"4"], [waypointOne5.position.x,waypointOne5.position.z,"5"], [waypointOne6.position.x,waypointOne6.position.z,"6"], [waypointOne7.position.x,waypointOne7.position.z,"7"], [waypointOne8.position.x,waypointOne8.position.z,"8"], [waypointOne9.position.x,waypointOne9.position.z,"9"], [waypointOne10.position.x,waypointOne10.position.z,"10"], [waypointOne11.position.x,waypointOne11.position.z,"11"], [waypointOne12.position.x,waypointOne12.position.z,"12"], [waypointOne13.position.x,waypointOne13.position.z,"13"],
[waypointOne14.position.x,waypointOne14.position.z,"14"], [waypointOne15.position.x,waypointOne15.position.z,"15"]
]; //waypoints for plazer 2 waypoints2 = [ [spawn2.position.x,spawn2.position.z,"0"], [waypointTwo1.position.x,waypointTwo1.position.z,"1"], [waypointTwo2.position.x,waypointTwo2.position.z,"2"], [waypointTwo3.position.x,waypointTwo3.position.z,"3"], [waypointTwo4.position.x,waypointTwo4.position.z,"4"], [waypointTwo5.position.x,waypointTwo5.position.z,"5"], [waypointTwo6.position.x,waypointTwo6.position.z,"6"], [waypointTwo7.position.x,waypointTwo7.position.z,"7"], [waypointTwo8.position.x,waypointTwo8.position.z,"8"], [waypointTwo9.position.x,waypointTwo9.position.z,"9"], [waypointTwo10.position.x,waypointTwo10.position.z,"10"], [waypointTwo11.position.x,waypointTwo11.position.z,"11"], [waypointTwo12.position.x,waypointTwo12.position.z,"12"], [waypointTwo13.position.x,waypointTwo13.position.z,"13"],
[waypointTwo14.position.x,waypointTwo14.position.z,"14"], [waypointTwo15.position.x,waypointTwo15.position.z,"15"]
];

 playerOne.transform.position.x = waypoints1[playerOnePoints][0];
 playerOne.transform.position.z = waypoints1[playerOnePoints][1];
 playerTwo.transform.position.x = waypoints2[playerTwoPoints][0];
 playerTwo.transform.position.z = waypoints2[playerTwoPoints][1];

}

// buttons and questions function OnGUI () { if( startGame == true) { GUI.Label (Rect (0,0,700,550),mainMenu); GUI.Label (Rect (Screen.width - (Screen.width/2)-100,Screen.height - (Screen.height/2)-300,200,100), "Sarah's Quiz"); if(GUI.Button (Rect (Screen.width - (Screen.width/2)-100,Screen.height - (Screen.height/2)-75,200,100), startGameButton)) { startGame = false; } if(GUI.Button (Rect (Screen.width - (Screen.width/2)-100,Screen.height - (Screen.height/2)+150,200,100), quitGameButton)) { Application.Quit(); } } else { GUI.skin = customSkin; // Make a background box
GUI.Label (Rect (25,500,4000,20),"Player Turn: " + currentPlayer); GUI.Label (Rect (25,50,4000,20),"Player 1 Score " + playerOnePoints); GUI.Label (Rect (25,100,4000,20),"Player 2 Score " + playerTwoPoints); if(winner) { if(GUI.Button (Rect (Screen.width - (Screen.width/2)+150,Screen.height - (Screen.height/2)+150,100,100), mainMenuButton)) { startGame = true; } } if(winner && currentPlayer == 1) { GUI.Label (Rect (Screen.width - (Screen.width/2),Screen.height - (Screen.height/2),700,550),playerOneWinner); }
if(winner && currentPlayer == 1) { GUI.Label (Rect (Screen.width - (Screen.width/2),Screen.height - (Screen.height/2),700,550),playerTwoWinner); } if(winner && currentPlayer == 3) { GUI.Label (Rect (Screen.width - (Screen.width/2),Screen.height - (Screen.height/2),700,550),TieWinner); }

         if((initialButton || continueCorrectButton || continueIncorrectButton))
         {
             if(GUI.Button (Rect (Screen.width - (Screen.width/2)+150,Screen.height - (Screen.height/2)+150,100,100), continueButton))
             {           

                 quizQuestions++;
                 answerMark = 0;
                 Debug.Log("CLICK!OK");
                 if(initialButton)
                 {
                     showQuestion = true;
                     initialButton = false;              
                 }
                 if(continueCorrectButton)
                 {               
                     Debug.Log("CORRECT");
                     AudioSource.PlayClipAtPoint(correctSound, Camera.main.transform.position);                      
                     move = 1;
                     questions[currentQuestion][6] = "1";
                     Debug.Log("A1");
                     continueCorrectButton = false;              

                     if(currentPlayer == 1)
                     {            
                         playerOnePoints++;                      
                         playerOne.transform.position.x = waypoints1[playerOnePoints][0];
                         playerOne.transform.position.z = waypoints1[playerOnePoints][1];
                     }
                     if(currentPlayer == 2)
                     {
                         playerTwoPoints++;                      
                         playerTwo.transform.position.x = waypoints2[playerTwoPoints][0];
                         playerTwo.transform.position.z = waypoints2[playerTwoPoints][1];                    
                     }
                 }
                 if(continueIncorrectButton)
                 {
                     questions[currentQuestion][6] = "1";
                     move = 2;
                     AudioSource.PlayClipAtPoint(incorrectSound, Camera.main.transform.position);
                     continueIncorrectButton = false;                        
                 }
                 if(quizQuestions == numOfQuestions)
                 {
                     Debug.Log("IN QUIZ QUESTIONS");
                     if(playerOnePoints == playerTwoPoints)
                     {
                         winner=true;
                         showQuestion = false;
                         currentPlayer = 3;
                         Debug.Log("HIDING!3");
                     }
                     else
                     {                       
                         if(playerOnePoints == ((numOfQuestions-1)/2))
                         {
                             showQuestion = false;
                             winner = true;
                             currentPlayer = 1;
                             Debug.Log("HIDING!1");
                         }
                         if(playerTwoPoints == ((numOfQuestions-1)/2))
                         {
                             winner=true;
                             showQuestion = false;
                             currentPlayer = 2;
                             Debug.Log("HIDING!2");
                         }
                     }                           
                 }
             }
         }

     if( showQuestion == true)
     {
         GUI.Label (Rect (Screen.width - (Screen.width/2)-200,Screen.height - (Screen.height/2)-350,700,550),questionBoard);
         GUI.Label (Rect (Screen.width - (Screen.width/2)+10,Screen.height - (Screen.height/2)-250,700,550),questions[currentQuestion][0]);
         GUI.Box (Rect (Screen.width - (Screen.width/2)-60,Screen.height - (Screen.height/2)-55,300,40), questions[currentQuestion][1]);
         GUI.Box (Rect (Screen.width - (Screen.width/2)-60,Screen.height - (Screen.height/2)+10,300,40), questions[currentQuestion][2]);
         GUI.Box (Rect (Screen.width - (Screen.width/2)-60,Screen.height - (Screen.height/2)+80,300,40), questions[currentQuestion][3]);
         //GUI.Label (Rect (85,240,4000,20), questions[currentQuestion][4]);

         ///// wINNER!
         if(winnerBanner)
         {
             GUI.Label (Rect (155,150,4000,20),"End of game " + currentPlayer + " Congratulations with ");
         }

         //// wINNER!


         // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
         if (GUI.Button (Rect (Screen.width - (Screen.width/2)-72,Screen.height - (Screen.height/2)-60,60,40),"   ")) 
         {
             answerMark = 1;             
             if(questionAllUsed)
             {
                 lastQuestionDone = true;
             }
             if(questions[currentQuestion][5] == "1")
             {
                 continueCorrectButton = true;                   
             }
             else
             {   
                 continueIncorrectButton = true;             
             }
         }

         // Make the second button.
         if (GUI.Button (Rect (Screen.width - (Screen.width/2)-72,Screen.height - (Screen.height/2),60,40),"   ")) 
         {
             answerMark = 2;
             if(questionAllUsed)
             {
                 lastQuestionDone = true;
             }       
             if(questions[currentQuestion][5] == "2")
             {
                 continueCorrectButton = true;                   
             }
             else
             {   
                 continueIncorrectButton = true;             
             }
         }

         // Make the third button.
         if (GUI.Button (Rect (Screen.width - (Screen.width/2)-72,Screen.height - (Screen.height/2)+72,60,40),"   ")) 
         {
             answerMark = 3;             
             if(questions[currentQuestion][5] == "3")
             {
                 continueCorrectButton = true;                   
             }
             else
             {   
                 continueIncorrectButton = true;             
             }
         }



         if( lastQuestionDone ) 
         {
             if(playerOnePoints > playerTwoPoints)
             {
                 winnerBanner = true;
                 finalScore = playerTwoPoints;
             }
             if(playerTwoPoints > playerOnePoints)
             {
                 winnerBanner = true;
                 finalScore = playerTwoPoints;
             }
             if(playerOnePoints == playerTwoPoints)
             {
                 winnerBanner = true;
                 finalScore = playerTwoPoints;
             }
         }
         else
         {
             if(initialButton == false && continueCorrectButton== false && continueIncorrectButton== false)
             {
                 GUI.Label (Rect (25,500,4000,20),"Player Turn: " + currentPlayer);
                 GUI.Label (Rect (25,100,4000,20),"Player 2 Score " + playerTwoPoints);
                 GUI.Label (Rect (25,50,4000,20),"Player 1 Score " + playerOnePoints);
                 questionCheck = 0;
                     while(questions[currentQuestion][6] == "1")
                     {                   
                         currentQuestion = parseInt(Random.Range(0,numOfQuestions-1));
                         if(questionCheck > numOfQuestions*2)
                         {
                             keepGoing = true;
                             for(n = 0; n < numOfQuestions && keepGoing; n++)
                             {               Debug.Log(n + "NNNNNNNN");              
                                 if( questions[n][6] == "0")
                                 {
                                     currentQuestion = n;
                                     n = numOfQuestions;
                                     keepGoing=false;
                                 }                                       
                             }
                             if(n > numOfQuestions)
                             {
                                 questionAllUsed = true;
                             }   
                         }
                         questionCheck++;
             }       }
         }
     if(answerMark == 1)
     {
         GUI.Label (Rect (Screen.width - (Screen.width/2)-53,Screen.height - (Screen.height/2)-67,60,40), goldStar);
     }
     if(answerMark == 2)
     {
         GUI.Label (Rect (Screen.width - (Screen.width/2)-53,Screen.height - (Screen.height/2)-6,60,40), goldStar);
     }
     if(answerMark == 3)
     {
         GUI.Label (Rect (Screen.width - (Screen.width/2)-53,Screen.height - (Screen.height/2)+63,60,40),goldStar);
     }
 }
 }
     if(escHit == true){

     //Backround for Exit Menu
     GUI.Box (Rect ((Screen.width/2)-100,(Screen.height/2)-25,300,100), "");     
     }
     // Clicking exit button
     if(escHit == true && GUI.Button (Rect ((Screen.width/2),(Screen.height/2),100,50), "Quit"))
     {
        Application.Quit();
     }

 }


function Update() { if( startGame == false) { // currentPlayer 1 if (lastQuestionDone == false) {
if( currentPlayer == 1 ) { if(move != 0) { //showQuestion = false;
currentPlayer = 2; move = 0;
} } //currentPlayer 2 if( currentPlayer == 2 ) { if(move != 0) { //showQuestion = false; currentPlayer = 1; move = 0;
}

         }
     }
     else
     { 

     }

     if(Input.GetKeyDown(KeyCode.Escape) && escTimer > 20)
     {           
         escTimer = 0;
         escHit = !escHit;
         scripts = !scripts;                 
         //Camera.main.GetComponent(Movementtest1).enabled = scripts;                
     }
     else
     {
         escTimer += 1;
     }
 }

}

Comment
Add comment · Show 2
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 · Mar 02, 2011 at 03:36 AM 0
Share

One thing I see in the first lines of code, ins$$anonymous$$d of having a bajillion separate-but-related variables, just use an array. It will make the code far shorter and simpler.

avatar image Raul 2 · Mar 03, 2011 at 12:25 AM 0
Share

Elaborate! please

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Mar 02, 2011 at 08:10 AM

Sometimes it helps to assign a complete triple all at once:

playerOne.transform.position = 
     new Vector3 (waypoints1[playerOnePoints][0], 0, waypoints1[playerOnePoints][1]);

Worth a shot.

Comment
Add comment · Show 3 · 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 Raul 2 · Mar 02, 2011 at 08:26 PM 0
Share

tried and it did not fix it, also it does not run through the whole code! It works perfectly in the editor! help!

avatar image DaveA · Mar 03, 2011 at 09:00 PM 0
Share

can you be more specific? If the code has changed, can you re-post (edit your question to add), and include the line indicator where it stops. You can also load it into the debugger and/or fill up on Debug.Log statements to make sure things are going where you expect them to.

avatar image Raul 2 · Mar 03, 2011 at 09:59 PM 0
Share

Its not really the code thats broken at all! When i compile the .exe its as though some of the code does not run through, Works perfectly in the editor... I am cleaning up and editing my code soon and will re-post it all, but im still wondering why it works in the editor but not the .exe

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

No one has followed this question yet.

Related Questions

Compiled project: Cannot move 1 Answer

Moving on uneven terrain issue 3 Answers

Problem with transform 2 Answers

Is it possible to get transform.Translate() to move like CharacterController.Move()? 0 Answers

Walls move when the character moves ! 4 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