Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Mission System

Discussion in 'Getting Started' started by BrewNCode, Apr 28, 2018.

  1. BrewNCode

    BrewNCode

    Joined:
    Feb 17, 2017
    Posts:
    372
    Hello. Do I want to know how can I tell to my players where they have to go? I have a little spaceship game that it needs to fly from planet to planet, so I want to tell the player that it needs to go to that specific planet. (Basically telling them that you need to go from Point A to Point B). How can I randomize this mission system? Like Saying, you are now on the earth, please Go to Neptune.

    Thank you beforehand.
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I'm unsure if this will fully answer your question, which at its core sounds like "How do I choose a random element from a collection?".
    From what you put forward as your example, with a list of possible locations, while you're at one, you could remove/ignore that particular place, and choose a random integer to use as an index for the collection.

    If your question has more to it, please explain. :)
     
    Kiwasi likes this.
  3. BrewNCode

    BrewNCode

    Joined:
    Feb 17, 2017
    Posts:
    372
    Yeah! you are getting there : D. Well, think about this. You are in a spaceship in our solar system. And you have to go from Mercury to the Earth, well, you go there. Then the game tells you to go from the Earth to Neptune, you go there. How can I do this?
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    If you're still asking about just getting a random element, you just need:
    1) a collection (of places).
    2) a random integer to index into the collection.
     
  5. BrewNCode

    BrewNCode

    Joined:
    Feb 17, 2017
    Posts:
    372
    and how about if I just update the text after a certain amount of time passes? for example, Say, 'Go to Mars' after some time, it says, 'Now, go to Neptune.' How can I do that? I don't know how to update the text after a certain amount of time passes.
     
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Maybe just set a "nextUpdate" float variable which could be Time.time + a variable float for how many seconds you want until the next mission update. Time.time is the current time, so if you add '10' for example, the nextUpdate variable would be 10 seconds in the future ;)
    Maybe from what you've shared, you'd want to set the next time to some amount after they arrive at their current destination.