How do i randomize?

Get help using Construct 3!

Post » Tue Sep 12, 2017 3:11 pm

Hey guys, i have a sprite with (eg) 4 frames.

i want that sprite to be in a random frame whenever it is spawned. Therefore i could use random(0,3)

The thing is, i will include more frames eventually, so, if in the end of my project the sprite has 10 frames, i should update the event to "random(0,9)"

isn't there a way to program it to "random(all frames)" or something similar so i don't have to update the precise range when i update the amount of frames?
B
5
Posts: 25
Reputation: 271

Post » Tue Sep 12, 2017 3:32 pm

int(random(Sprite.AnimationFrameCount+1))
ImageImageImage
B
71
S
22
G
241
Posts: 3,734
Reputation: 134,494

Post » Tue Sep 12, 2017 7:17 pm

blackhornet wrote:int(random(Sprite.AnimationFrameCount+1))




i'll try it out, thanks!
B
5
Posts: 25
Reputation: 271


Return to How do I...?

Who is online

Users browsing this forum: No registered users and 0 guests