Random Problem
ricardorauber
Member Posts: 26
Hello there! I have a problem with random function when it's called from a spawned actor.
I have 2 actors, let me explain what they do:
Actor 1:
Rule - mouse button is down
Spawn Actor 2
Actor 2:
Display Text - random(1,100)
Timer - After 2 seconds
Destroy
Ok, what's the problem? When I click on the Actor 1, the Actor 2 appear with some value and after 2 seconds it left. The problem is that every time one Actor 2 is spawned, it always came with the same value!
Example:
I click on Actor 1;
Actor 2 appear with value 32;
After 2 seconds Actor 2 disappear;
I click again on Actor 1;
Actor 2 appear with the same 32 value!
Why the value is not random??
I have 2 actors, let me explain what they do:
Actor 1:
Rule - mouse button is down
Spawn Actor 2
Actor 2:
Display Text - random(1,100)
Timer - After 2 seconds
Destroy
Ok, what's the problem? When I click on the Actor 1, the Actor 2 appear with some value and after 2 seconds it left. The problem is that every time one Actor 2 is spawned, it always came with the same value!
Example:
I click on Actor 1;
Actor 2 appear with value 32;
After 2 seconds Actor 2 disappear;
I click again on Actor 1;
Actor 2 appear with the same 32 value!
Why the value is not random??
Comments
Thanks for the reply but it doesn't work, I'm still getting the same value!
When I click 2 times on Actor 1, the second one appear with other value but it seems to be always the same numbers.
One way of working it, would be to make your Actor 2 with 0 Alpha. Also, to avoid double clicks, make a game attribute called Active, for instance. In Actor 1's Rules, not only put when mouse button is down but also when game.Active is false, then change game.Active to True, and add Change Attribute, making Actor 2's Alpha to 1.
In Actor2, your random stuff, then a 2 sec. timer to change its Alpha to 0, and another Change Attribute, seting Active to false.
Hope that makes sense the way i've written it and hope it helps.
:-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
http://gamesalad.com/forums/topic.php?id=862
So why hasnt it been fixed yet? Why are people expected to have to figure out work arounds for a function that has been in the engine/editor for so long, but just isnt working correctly? Is it even in a GameSalad bugfix list?
This is a pretty major function for game development, and pretty shabby for it to not work correctly for so long.... its the kind of basic engine maintenance that should be top priority when it comes to the updates.
Please Gendai, concentrate on fixing broken stuff, and improve the editor, rather than worrying about new features all the time.... and you'd make me a happy developer.
But as far as I've found, although random doesn't work in Display text, by changing an attribute Rand on mouse up for instance, to random(min,max), then the Text in Display Text to be self.Rand, (I know you guys know that) you get pretty much random numbers, although I'm told not true random, but the randomness seems good enough to me!
I'm guessing the broken random your referring to is random in Display Text?
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Following that topic that scitunes said, I'm using the milliseconds to get some random numbers but even that doesn't work perfect.
First of all, there is no problem with the random function. What happened is that Display Text on the spawned actor changes only on the first time! I put other actor displaying the same game attribute and it worked perfect.
With these things, I had the change the logic and now works!
Once again, thanks for all replys!
I'm becoming crazy with this random value, I need one when the game starts and I can't use game.time because, of course, is always the same.