i am trying to make animation to be set randomly every time a certain amount of time passes and then the timer starts again
i am doing it like this but it’s not working
i am trying to make animation to be set randomly every time a certain amount of time passes and then the timer starts again
Hello, OwO
I did some testing and my guess is that every frame Gdevelop reads the condition and randomises the number. This means that it will be almost impossible to get close to 20 seconds since at some point it will randomise a number very close to 15.
I think is better you randomise a variable.
Condition used is called Compare Two Numbers
2 is how many seconds
1 is at what second to check
1 CANNOT be higher or equal to 2 it always need to be lower
So for example you can have mod(TimeFromStart(),20) > 19
Or mod(TimeFromStart(),20) > 7
But you cant have
mod(TimeFromStart(),20) > 20
Or
mod(TimeFromStart(),20) = 20
So this mod(TimeFromStart(),20) > 19
Means it will loop 20 seconds
So it will happen 3 times each minute
19 means it will happen at each 19th second
So at 19 then at 39 then at 59
Which still are 20 seconds intervals
My example is for 2 secs loop so it will happen 30 times per minute
So i did as you said and it works but i want to hide or change it’s animation to empty but if I do it as below it just chooses an animation and sets to empty instantly.
Hello i did thought about it but i thought maybe there is a simpler way
I am keeping the variable if it doesn’t work.
I did not use for each object in my event so why you use it in yours?
And using wait inside for each is wrong
You are bugging it out
Or to be precise you are spamming it
Anyway why wait 3 secs?
You want animation to play for 3 secs and then change to empty?
So why not use my event checking if its > 1 to set random animation
And then If its > 4 set it to empty?
You would get exactly to what you want to achieve
My bad
i did as you said and it is working
just one thing all of the animation are changing at the same time is there a way to randomize the time for each instance?
Remove what is in red box if you want objects to play animation at same intervals
FOR EXAMPLE 1st ball would play animation at 2nd second then it would do it for 3 secs
Then it would reset timer and wait 2 secs again then play for 3 secs again
Above is what will happen with action in red box
Without it
At beginning of scene object get random number of 2
It waits to 2nd second and for 3 secs play animation
After that it resets timer but also give it another random second
So it won’t be 2nd second (well it could) but a random now
So for example now it could wait 6 seconds before it plays animation
And after finishing animation it would get new random second
IF YOU KEEP ACTION IN RED BOX
I went with RandomFloatInRange
Cause
Random in range 1 , 10 will give you either 1 2 3 4 5 6 7 8 9 or 10
RandomFloatInRange will give you anything between 1.0 to 10.0
So it can be 1.1 1.2 1.3 1.4 and so go on
It includes decimals
And that feels MORE naturall/random
Cause with random in range if 2 objects get for example 5 they gonna start animation in same moment and that looks robotic
With float in range one can get 5 while other will get 5.2
And you can see they did not start at the same exact moment
But close to each other
And it does feel better but it is for you to judge
I do not have like moving animation i have still images with different colors
So to mimic animations i spin them for these 3 secs you want
So what you see in my events actions for rotate and ballz is something just for me to fake animation
Enjoy
You need to reset the timer on NpcExpressionsPoPUP when you change the object’s animation. Otherwise the random animation action will possibly end up being run multiple times per second.
Thank you it’s working just the way i wanted!
Yes I was encountering that problem but it is working now