can i exclude a number from a random number?
hi, i have a actor that when collides with trigger it changes self. att. direction to random(1,4)
when self. direction =1 move 0 degrees related to scene.
when self. direction =2 move 180 degrees related to scene.
when self. direction =3 move 90 degrees related to scene.
when self. direction =4 move 270 degrees related to scene. but i would like to exclude the attribute from the direction is coming. say if direction is 0, then to choose a random from 2,3,4
if direction is 180 to chose random from 1,3,4
pretty much i don't want to go back from the direction is coming. thanks in advance
when self. direction =1 move 0 degrees related to scene.
when self. direction =2 move 180 degrees related to scene.
when self. direction =3 move 90 degrees related to scene.
when self. direction =4 move 270 degrees related to scene. but i would like to exclude the attribute from the direction is coming. say if direction is 0, then to choose a random from 2,3,4
if direction is 180 to chose random from 1,3,4
pretty much i don't want to go back from the direction is coming. thanks in advance
Comments
so change self.direction to random(1,4)
then in the same rule change lastDirection to self direction
then another rule if lastDirection = self.direction
change self.direction to random(1,4)
what that will do is as soon as the random number is the same as the last number it pulled, itll change it again and keep changing till its not the same
There might be a better way to do it, but that should work
cheers
i.e.
if lastDirection = self.direction
change self.direction to random(1,4)
otherwise:
change.self.direction to random (1,4)
change lastDirection to self.direction
or is my logic wrong? Trying to tune my brain into this kind of thing so apologies if incorrect.
Rule - If att = 8 Random Number.
So it'll keep randomising till it gets a different one.
Easy
I was also gonna suggest something like
If attribute is not 8
Then blah blah blah
But the other way seems better
column 1 <2,3,4>
column 2 <1,3,4>
column 3 <1,2,4>
column 4 <1,2,3>
Type everything in as shown then in your rule use the following..
when self.Direction=1 change self.Att to tableCellValue(Table1,random(1,3),column 1)
when self.Direction=2 change self.Att to tableCellValue(Table1,random(1,3),column 2)
when self.Direction=3 change self.Att to tableCellValue(Table1,random(1,3),column 3)
when self.Direction=4 change self.Att to tableCellValue(Table1,random(1,3),column 4)
I havent tested it but that should work for you!
Goodluck,
Aaron