Set frame duration for an animation through a behavior

FireDart

  • Posts: 2
Hello!
 I’ve spent some time on the forums looking for the answer to my question but didn’t manage to find anything,  so here I am.
I’d like my game to have a sort of cast-time mechanic where how quickly the player runs through their attack animation is based on their AttackSpeed stat, found in a game list. I tried a method where the frames were set to 1000ms each and in the attack behavior it would switch to the attack animation and then have:
Do after (AttackSpeed) seconds
 -Switch to frame ((Get current frame for self) + 1),

But that didn’t work, even after stringing a few together to perform the entire animation. I can’t seem to find any blocks to set the duration of frames in an animation equal to an attribute before executing the attack animation.  Am I missing something, or is this a task that will require a kind of custom block?
 If someone has already asked this question and I just completely missed the thread, it’d be great if someone could point me in that direction. Thanks for your time!

Luyren

  • *
  • Posts: 2682

Applies to the current frame.

You might be better off constantly setting to the same frame, and advance the frame through a number attribute on your own terms. Unless you provide a screenshot of your attempted code and describe what is happening with that code, it's hard to make specific suggestions.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter

FireDart

  • Posts: 2
Sorry I didn’t attach a screenshot, there’re a whole lot of things unrelated to the question going on in that behavior and I didn’t want to overwhelm people.
 I did find a solution though, and it took way longer than it should’ve had to come up with it I’ll put it here for anyone who may end up going through the same issue..

When Updating
 If ((current animation for self) = (AttackR) or (current animation for self) = (AttackL)
  Set duration of frame (current frame) to (AttackSpeed)

Luyren

  • *
  • Posts: 2682
Sorry I didn’t attach a screenshot, there’re a whole lot of things unrelated to the question going on in that behavior and I didn’t want to overwhelm people.
 I did find a solution though, and it took way longer than it should’ve had to come up with it I’ll put it here for anyone who may end up going through the same issue..

When Updating
 If ((current animation for self) = (AttackR) or (current animation for self) = (AttackL)
  Set duration of frame (current frame) to (AttackSpeed)
Might not affect your specific case, but beware that changing the duration of a frame is permanent. Even if you switch animations, the actor will still have that frame duration with the value you set.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.
Twitter