Help with spawning different actors
Please help me fix the problem that I have encountered or offer an alternative idea. So I have a timer that changes an attribute called PickPlayer randomly from 1 to 7 every 2 seconds to 3 seconds(randomly). The six spawners in the game respond to the value of PickPlayer with the actor that corresponds to the value of PickPlayer. For example, one spawner would respond to a PickPlayer value of 2 with a blue circle but another spawner could respond to the value of 2 with a red circle. It is a complicated system but I am having a problem with it. If the value of PickPlayer is the same value of what it was 2 seconds ago, no players spawn with the corresponding value. This is understandable because the spawners believe that there is no reason to spawn the character again. So the question is, how do I change the PickPlayer so that when it chooses randomly between 1 and 7 it won't choose the value it had 2 seconds ago? There has to be a "anything but" expression that will prevent the same number. Please help me!
Comments
Try making an attribute called 'LastRandom' and save the random number to it.
Then when you get a new random number compare your new random number to 'LastRandom' and if they match either choose a fresh random number until it doesn't match, or, if the number is 6 or lower add 1, or subtract 1 if the number is 7.
The second part is a dirty pseudo random way to get an answer, but it works.
@Emmett17 Here is a very simple project for you to look at. Took me a while to find our thread as the spam bots have been out in force!
All the logic is in the 'Randomise' actor.
But all is does is set up two attributes, one that stores the newly generated random number and one that stores the old random number. If the newly generated random number is the same as the old number then it waits 3 seconds before changing the new number to a different number. There is no real reason for the pause, bar that it allows us to see the matching numbers (if they match) and then how they change.
The logic for the change is - if the new number is less that 7 add 1 to it, if it is already 7 then subtract 1 from it.
Have a play and see what happens.
https://www.dropbox.com/s/45ed5b4dtlhiuz1/PseudoRandom.zip?dl=0