Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Missions

Discussion in 'Getting Started' started by joytdecastro, Feb 15, 2015.

  1. joytdecastro

    joytdecastro

    Joined:
    Feb 15, 2015
    Posts:
    21
    we are creating a game with different levels, each levels have 3 mission, but we don't know how to create 3 missions in one level. please help!! thanks in advance :)
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    Sorry, that's not nearly enough information for anyone to help you.

    Generally, people find better help here if you post code, screenshots, and ask for specific issues you're having, instead of asking for high-level "How do I do this?" kind of things.

    What is a mission? Is it just a small level? Is it an objective the player has to complete? Do you have code in place to get one mission working, but you need help getting the game to require 3 of them? The more specific info you can provide, the better your chance of receiving assistance.
     
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,446
    Why not simply create three copies of the level?
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Exercise - What is a mission?

    Possible answers
    • The user has to collect a certain number of items to complete each mission
    • The user has to complete some arbitrary objective
    • The user can choose between completing one of three options, thereby modifying the game story
    Good code will flow naturally out of a good description of functionality.

    In general terms a mission system consists of the following
    • A way for the user to view active quests and progress
    • A way for the user to gain new quests
    • A way for the game to detect progress on a quest and if a quest is completed
     
  5. joytdecastro

    joytdecastro

    Joined:
    Feb 15, 2015
    Posts:
    21
    sorry if i did not explain it clearly, well that's actually my problem, i don't have enough knowledge in making a game in unity specially in scripting, sorry again
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    This is nothing to do with scripting, and everything to do with design. Provide a good plain English description of your objectives, and we can help out with the scripting.
     
  7. joytdecastro

    joytdecastro

    Joined:
    Feb 15, 2015
    Posts:
    21
    yeah, we did that but our concern on our game was, every level has 3 missions, but i don't know how to create 3 missions in one level.. actually i have a script but it only have one mission, here it is

    function Update () {

    if(currentScore >= 500) {
    Application.LoadLevel ("mission complete1");
    }
    }

    if i'm going to continue it with else if statement, and make another mission, for example, if the player get 3 power up and get that 500 coins then that will only the time for Application.LoadLevel ("mission complete1");

    well that's basically my problem.. i'm a newbie, sorry
     
  8. joytdecastro

    joytdecastro

    Joined:
    Feb 15, 2015
    Posts:
    21
    actually i only have 1 mission for now, its was like, if the character reach 500 coins then the game will stop and there a scene will show saying "mission complete", but we at least need 3 missions.. when the player reach that 3 missions that's the time the mission complete will show. sorry i'm not really good in english language, sorry
     
  9. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,660
    OK, so you mean the player has 3 'objectives' rather than 3 'missions.'

    Objective 1: Collect 500 coins
    Objective 2: ???????
    Objective 3: ???????

    What are objectives 2 and 3?
     
    Kiwasi likes this.
  10. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    As @superpig alluded to, you have to be able to describe what the other two missions/objectives are. As far as scripting goes, instead of just loading the next level when the player has accomplished one mission, check to see if they've completed all of them.

    Code (JavaScript):
    1. var isObjective1Complete : boolean = false;
    2. var isObjective2Complete : boolean = false;
    3. var isObjective3Complete : boolean = false;
    4.  
    5. function Update () {
    6.   if (currentScore >= 500) {
    7.     isObjective1Complete = true;
    8.     Debug.Log("You completed goal 1!");
    9.   }
    10.   if (bossKilled = true) {
    11.     isObjective2Complete = true;
    12.     Debug.Log("You completed goal 2!");
    13.   }
    14.   if (stdsAcquired < 3) {
    15.     isObjective3Complete = true;
    16.     Debug.Log("You completed goal 3!");
    17.   }
    18.   if (isObjective1Complete && isObjective2Complete && isObjective3Complete) {
    19.     Application.LoadLevel ("NextLevel");
    20.   }
    21. }
    There's certainly way more efficient ways of handling this, but it should give you the idea, anyway.
     
    Kiwasi likes this.
  11. joytdecastro

    joytdecastro

    Joined:
    Feb 15, 2015
    Posts:
    21
    @Schneider21 thanks for the script, i will try that script
     
  12. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    I'd just like to point out @joytdecastro that the script I provided won't just work on its own. The individual objective goals will still need to be set from elsewhere once those tasks are completed. My intent was just to lead you in the right direction.
     
  13. joytdecastro

    joytdecastro

    Joined:
    Feb 15, 2015
    Posts:
    21
    ah yeah thank you sir, well, i think i still can't do it because i don't still have our power ups.
     
  14. bigSadFace

    bigSadFace

    Joined:
    Aug 18, 2014
    Posts:
    116
    joytdecastro, if you answer the above I am sure you will get the exact answer you are looking for. Your first mission is collect 500 coins? What is mission 2 and 3 in the same level?
     
    Kiwasi likes this.
  15. joytdecastro

    joytdecastro

    Joined:
    Feb 15, 2015
    Posts:
    21
    for the mission 2 is to collect 5 power up that has tag "PowerUp" and for mission 3 is to score 5000 points, but i'm having problem for the mission 3 because i'm going to get the score from different script, but it is from c# script, and i'm using a js script. and i don't know how to convert it to js script.. but here's my code for the c#

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class GameControlScript : MonoBehaviour {
    5.    
    6.     public GUISkin skin;
    7.     float timeRemaining = 500;
    8.     float timeExtension = 3f;
    9.     float timeDeduction = 2f;
    10.     float totalTimeElapsed = 0;
    11.     float score=0f;
    12.     public bool isGameOver = false;
    13.    
    14.     void Start(){
    15.         Time.timeScale = 1;  // set the time scale to 1, to start the game world. This is needed if you restart the game from the game over menu
    16.     }
    17.    
    18.     void Update () {
    19.         if(isGameOver)
    20.             return;
    21.        
    22.         totalTimeElapsed += Time.deltaTime;
    23.         score = totalTimeElapsed*100;
    24.         timeRemaining -= Time.deltaTime;
    25.         if(timeRemaining <= 0){
    26.             isGameOver = true;
    27.         }
    28.     }
    29.    
    30.     public void PowerupCollected()
    31.     {
    32.         timeRemaining += timeExtension;
    33.     }
    34.    
    35.     public void AlcoholCollected()
    36.     {
    37.         timeRemaining -= timeDeduction;
    38.     }
    39.    
    40.     void OnGUI()
    41.     {
    42.         GUI.skin=skin; //use the skin in game over menu
    43.         //check if game is not over, if so, display the score and the time left
    44.         if(!isGameOver)  
    45.         {
    46.             //GUI.Label(new Rect(10, 10, Screen.width/5, Screen.height/6),"TIME LEFT: "+((int)timeRemaining).ToString());
    47.             GUI.Label(new Rect(Screen.width-(Screen.width/10), 10, Screen.width/10, Screen.height/10), "SCORE: "+((int)score).ToString());
    48.         }
    49.         //if game over, display game over menu with score
    50.         else
    51.         {
    52.             Time.timeScale = 0; //set the timescale to zero so as to stop the game world
    53.            
    54.             //display the final score
    55.             GUI.Box(new Rect(Screen.width/4, Screen.height/4, Screen.width/2, Screen.height/2), "GAME OVER\nYOUR SCORE: "+(int)score);
    56.            
    57.             //restart the game on click
    58.             if (GUI.Button(new Rect(Screen.width/4+10, Screen.height/4+Screen.height/10+10, Screen.width/2-20, Screen.height/10), "RESTART")){
    59.                 Application.LoadLevel(Application.loadedLevel);
    60.             }
    61.            
    62.             //load the main menu, which as of now has not been created
    63.             if (GUI.Button(new Rect(Screen.width/4+10, Screen.height/4+2*Screen.height/10+10, Screen.width/2-20, Screen.height/10), "MAIN MENU")){
    64.                 Application.LoadLevel(0);
    65.             }
    66.            
    67.             //exit the game
    68.             if (GUI.Button(new Rect(Screen.width/4+10, Screen.height/4+3*Screen.height/10+10, Screen.width/2-20, Screen.height/10), "EXIT GAME")){
    69.                 Application.Quit();
    70.             }
    71.         }
    72.     }
    73. }