Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

How to have duplicate randomizers in the same FixedLengthScenario?

Discussion in 'Computer Vision' started by ComeOnAndSam, May 8, 2021.

  1. ComeOnAndSam

    ComeOnAndSam

    Joined:
    Nov 8, 2016
    Posts:
    62
    I made a randomizer that takes a list of selected locations and randomly places a GameObjectParameter prefab there. But the intention is for there to be multiple of this randomizer, because each one would take a different set of locations to spawn a different set of prefabs there, because what can be spawned is mutually exclusive to its location.

    But I can't have duplicate randomizers. Once one is added to the FixedLengthScenario, it disappears from the Add Randomizer list and can't be added again. I get that in the case of the example randomizers, duplication is unnecessary and would break it. But with my custom randomizer, it is not, and in fact essential for there to be duplicates. How do I get around this? How do I make it so my custom randomizer can be added to the same scenario multiple times?
     
  2. JonHUnity

    JonHUnity

    Joined:
    Sep 16, 2016
    Posts:
    21
    The best approach for this is to create a RandomizerTag-derived class to capture these locations. Then in your scene you can create GameObjects with these tag components to define the individual locations. The randomizer can then query for these tags using tagManager.Query<>() and choose locations to spawn objects in any manner it chooses.
     
  3. Steven-CV

    Steven-CV

    Unity Technologies

    Joined:
    Jul 25, 2019
    Posts:
    5