It seems like my original question has been deleted:
It doesn't exist.
I have explained what is my problem is and what actions I tried to solve the problem on my own.
Anyone able to explain it to me why is my topic has been deleted?
Fortunately I always copy the text before submit so here we go again, if there is any problem with it, please explain.
I was searching the forum but can not find the answer.
I'm creating 10 instances of the same object at the start of the layout and what I'm trying to do is set their animation to be a random animation for each instance but I can't get it to work.
I have 3 animations and I named them 0,1 and 2 to be able to set the animation randomly using the random() expression.
Basically, this is what it looks like:
On start of layout:
sub->Repeat 10 times : Create object
: Set animation to str(random(2))[/code:8jiwq5dk]
But it doesn't work. Each instance display the first animation like nothing happened.
I have even tried using an instance variable. First generate a random value, store it inside an instance variable and use the variable to change the animation but I get the same result. I have also tried using the For each condition after all the objects are created:
[code:8jiwq5dk]On start of layout:
sub->Repeat 10 times : Create object
: Set animation to random(2) //this is an instance variable of object
sub->For each object : Set animation to str(object.animation) [/code:8jiwq5dk]
It didn't work either.
The only thing I managed to get to work is a counter variable. I increasing the value of the variable after each instance created and use that to set the animation.
[code:8jiwq5dk]On start of layout:
sub-> Local number counter = 0
sub->Repeat 10 times : Create object
: Set animation to str(counter)
: Add 1 to counter
sub->-> counter = 3 : Set counter to 0[/code:8jiwq5dk]
This is the only thing that works and set the animation of each instance to be different but it is not exactly what I want.
Anyone could help me please how to set random animation for each instance?
Thanks.