i'm currently trying to create an animated sprite that has three images it cycles through, I want the animation to as it selects the next frame for it to be a random one of the three images, I also want it to as it cycles through to randomise the speed as to which the animation plays, I'm fairly new to this is there a loop or something i could use to make this cycle of randomisation repeat over?
this is my code so far:
class_name SpriteFrameResource
const name: String = "walk"
var imageOne = load("res://Assets/Person Still.png")
var imageTwo = load("res://Assets/Person Step 1.png")
var imageThree = load("res://Assets/Person Walking.png")
var randomimage = rand_range(0, 2)
func getFrames() -> SpriteFrames:
if randomimage == 0:
imagenumber = imageOne
elif randomimage == 1:
imagenumber = imageTwo
else:
imagenumber = imageThree
self.add_animation(name)
self.add_frame(name, imagenumber)
self.add_frame(name, imagenumber)
self.add_frame(name, imagenumber)
self.set_animation_loop(name, true)
self.set_animation_speed(name, rand_range(1, 5))
return self