I'm loosing my mind. I've wasted several hours now trying to get this working, tried extensively googling my problem, tried asking chatgpt; and i'm getting nowhere.
I have a generic 2d npc that i'm trying to code so that you can essentially skin it to be any unique npc using sprite sheets, so that I don't have to set up each individual npc's animations, and save myself time in the future.
I'm using RPG maker style 3x4 cell sprite sheets where each row is a different animation, and the columns are the frames.
I want to be able to have an exposed variable in the inspector tab where I can just drag and drop the sprite sheet for unique instances of this npc when I add them to a room/level scene, and have the npc's script generate it's animations on the fly.
I'm very new to scripting in godot, and it's been really difficult, but I really want to move away from game maker studio 2 (the engine I was using before)
When I try googling anything along the lines of "godot 4 animation script" or "godot 4 animation code" or the like, I don't find anything relevant, and all the posts seem to just say to manually set up the animations in the animations tab of an animated sprite2d node; which is the whole thing i'm trying to avoid doing.
Surely there has to be some way to import a sprite sheet through an exposed variable in the inspector tab, and then use scripting to dynamically generate animations by carving up the sprite sheet, right? Surely, right?
I feel like it should be as easy as dividing the width of the sprite sheet by 3, the height by 4, and then iterating through a dictionary with the names of the 4 animation directions (down, up, left, right) and then iterating through and assigning them frames cropped from the sprite sheet. It sounds simple, but i'm really struggling to figure it out. If someone could help me you'd be a lifesaver.
I don't want to have to manually set up 100's of npc animations.