How to control the animation frame number to execute the corresponding script

I’m having a problem I don’t know how to get animation frames
I need to create the ghost body in the third frame of the animation
The animation plays to frame 27 to remove the ghost body

Some information about animation attack judgment
This video shows Elden Ring BOSS attack Weapon collision
You can see that collision judgments are not always present during the attack animation

I can’t find how to implement this in JME
I need some help

You can do something like this:

Tweens.parallel(
       attackAction,
       sequence(delay(t1), callMethod("enableGhostCollision"), delay(t2), callMethod("disableGhostCollision") )
);
2 Likes

Ok, thank you for your help. I will reply to you after trying:)

1 Like

delay(t1)

  • How do you represent the exact number of seconds If the t1 = 1f, Whether t1 is 1 second.
    :thinking:

Delay takes time in seconds. You can pass it a float number (e.g. 0.3, 1.875,…). You should select the time based on the animation. For example, if you want to run your code after 0.5 seconds passed in animation then you use delay(0.5).

I referenced blender timeline but found that the ghost body appearance time and animation were not aligned

Tween doneTween = Tweens.parallel(action,sequence(delay((1f/24f)*16f), Tweens.callMethod(this,"enableGhostCollision"), delay((1f/24f)*18f), Tweens.callMethod(this,"disableGhostCollision"), delay((1f/24f)*38f), Tweens.callMethod(this,"stopCurrentAnim")));

I guess 24 frames in 1 second
so delay((1f/24f)*16f) Represents the number of seconds of 16 frames
I don’t know if I understand correctly

Use percentage instead:


//`desiredFrame` is the frame you want to trigger the method

double delay1 = (desiredFrame1 / (double) numTotalFrames) * action.getLength();
double delay2 = (desiredFrame2 / (double) numTotalFrames) * action.getLength();

Tweens.parallel(
      sequence(action, callMethod(this,"stopCurrentAnim")),
      sequence(delay(delay1), callMethod(this,"enableGhostCollision")), 
      sequence(delay(delay2), callMethod(this,"disableGhostCollision"))
);

void
Thank you very much for your help
You can see in the video that the ghost body appears at the right time :smiling_face_with_three_hearts:

1 Like

You’re welcome! Glad you solved it. :slightly_smiling_face: