Right now I’m using this function to render sprites
local function SetDirection(sprite, direction, deltaTime)
sprite.Image = tostring("rbxassetid://" .. require(sprite.Parent.Parent.SpriteSheet)[sprite.Parent.Parent.Parent:GetAttribute("Action")][direction][1]["Image_ID"])
end
With [1] being the first frame of the direction table
["Idle"] = {
["Front"] = {
{["Image_ID"] = "Insert asset id here", ["Time"] = 0.25},
{["Image_ID"] = "Insert asset ID here", ["Time"] = 0.15}
}
Essentially I want every frame in the direction table to play through for it’s set duration of time, before looping back to the first frame
For example in the above image:
- Set the Image ID to Image_ID of the first table for [“Time”] seconds
- Switches to the same for the second table
- Iterates back to the first table
Since SetDirection operates through RenderStepped, and is general script meant to affect every tagged “sprite instance” I can’t think of how I would set this up to iterate through every “sprite” instances frames, which would all have varying amounts of frames at varying times
Also would it even be best to handle this in the directional sprite handler? Or have a separate “animator” script which sets the frames that would be output to the sprite handler
I feel like I would possibly be able to do something with for loops but putting a for loop to run every render step obviously isn’t feasible or functional, and I’d be worried about that tanking performance