Random Function Workaround, or Resolved?
butterbean
Member Posts: 4,315
I noticed people were having trouble with the "Random" function.
Is there a workaround to this? Or has this been resolved?
I'm trying to randomize the position of an actor after they perform a task
any help appreciated!
Is there a workaround to this? Or has this been resolved?
I'm trying to randomize the position of an actor after they perform a task
any help appreciated!
Comments
I'm trying to randomize an enemy's position once they've fired at the player, but the random function doesn't seem to work
I'm using "Interpolate" self.position X to random (340,750,890,1020) <---- These are random X coordinates. (timer over 1.5 seconds)
It doesn't seem to randomize the position, but perhaps someone could shed light as to what I might be doing wrong?
If the latter:
Interpolate self.position.x to random(0,480)
Interpolate self.position.y to random(0,320)
The random function only accepts 2 parameters, and it looks like you are feeding it 4 "random (340,750,890,1020)", which wouldn't work.
So should I assign the random to an integer attribute?
What would be the best way to set that up? Sorry, I think I have an idea but just want to make sure
Thanks again!
So random(0,480) will give you a random integer between 0 and 480.
You cannot have:
random(340,750,890,1020)
If you want something like that, you need to set up Rules.
Change Attribute: self.myRandomNumber To: random(1,4)
Rule
If self.myRandomNumber = 1
-----Change Attribute: self.spawnPosition To 340
otherwise
-----Rule
-----If self.myRandomNumber = 2
----------Change Attribute: self.spawnPosition To 750
etc..