Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Making a MK-Style enemy tower.

Discussion in 'Scripting' started by MrZeker, Jun 16, 2019.

  1. MrZeker

    MrZeker

    Joined:
    Nov 23, 2018
    Posts:
    227
    Hello, im trying to make a -kinda tower- enemy selectiong screen.
    What im essentially trying is to make something around the classic mortal kombat style:


    where you can choose from 3-4 towers with various enemies.
    What would be the best way to do it? Im using Scriptable objects for the enemies data.
    what i dont know how to do is to make the script pick enemies randomly but without repeating those that are already picked.
    Im open to suggestions, what i got right now would be:
    Using pre-made Array containing the IDS of the characters like
    Array (21, 23, 24, 22, etc) (22 being an INT that is the Character ID for the game).
     
  2. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    You copy the array into a new list, pick a random one out of that list and remove it from said list to avoid repeats.
     
  3. MrZeker

    MrZeker

    Joined:
    Nov 23, 2018
    Posts:
    227
    shouldn't i use a list from the start?
    also, since every character portrait should change based on the random ID number i get, what would be the best way to do it without doing one switch for every portrait( thats gonna be like 40+ switches in the script).
     
  4. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    If you want the original array to be a list go right ahead, you can also make the copy an array but it will be more work to remove items. The main thing is having a copy you modify and the original that is untouched.

    I didn't understand what you said about the ID and the switches.