Possible to pause 10 frame object animation on 9 and continue on key release?

I have what is intended to be a spring loaded lever that is pulled down with key press in its animation and flung up on key release. I am “porting” an old blender project to UE4 in which I had used 10 frames to achieve the desired result. I would play the animation from 0 to 9 (9th frame the lever is pulled at max) and run from frame 9 to 10 upon key release. The last frame is just a jump from max position to min. I can play the animation but I’m not seeing any options that indicate I can use this the same way. Would it be better to mocup a new 1 frame animation (though I’m not sure how to export two anims in an object from blender). If I were to import the same lever with just the last frame would I select the existing skeletal mesh I’ve already imported? I obviously wouldn’t need another lever object just the new animation in the FBX.

I was thinking I could pause the animation with a notify on frame 9 but I’d rather not use animation blueprints. Perhaps it could be most effective to have two animations. In that case, I just need to know how to import it properly.

UE4!
:smiley:

Minor update I have part of the desired behavior using Set Position when the key is released but I’m still short of the lever stopping at the end (or pausing). Can Set Position be used to hold the animation at a certain point?

Also curious if there is any other way to seemingly load the animation to the skeletal mesh without playing it.

The short answer is: I think you’re looking for “Set Play Rate”, I’m pretty sure you can set the rate to 0.

Longer answer, two animations (one for down and one for up) is probably the cleanest way to do that, but if you only have one, I think you could do something fairly clean with anim notifies that would work pretty well.

First, you’ll need to add an anim notify to your animation. It’s not tricky, you just need to know where to look. These two things can probably set you right:

Put your notify at the moment the lever reaches its lowest point, and when it goes off pause the animation. If you’re paused when the space bar is released, you just resume the animation.

One thing that I’m not clear on is if you intend for the lever to play its complete animation (all the way down, then back up) if the player just taps the spacebar for an instance. If you only want to pull the lever part way then go back up without playing the full top to bottom to top animation… I’m not sure how you’d do that with the setup you’re using (since you’d need to sync up the location you’re at on the “down” part of the animation with the location you’re at on the “back up” part of the animation.

Something a little messy to consider is only using the first half of the animation. Play it forward from the up position all the way to the down position and then pause. At any point in the animation, if the player releases space bar, you can play the animation backward (“Set Reverse”) at a very high play rate. That way it will snap back to the start position from wherever it is in the down movement.

Thank you for the response! Interesting, I hadn’t considered 0 play rate. As it stands with the displayed image I sort of get two thirds of the desired behavior. On first press it will “stage” the animation, playing the animation once completely (which is undesired). The next press / release acts better as a short press will move the lever down a tiny bit then back to resting position. I intend to have the lever figuratively held down at a maximum point until key release. Like time held with a max value. The time range will be between a few seconds its like a power charge you have to time within a window but it doesn’t go back down as its held its only reaching max shot power. A short tap will be a very weak shot only moving the lever a small amount.

That is what I was looking for thank you again! Understanding blueprints and power of nodes with their simplistic appearing options is a bit tricky at times. I think to myself there must be a way to pause animations but I don’t think to pause animations by setting play rate to 0.0 (which is obvious once I think about it).

I had setup an animation BP prior to posting my question, however I don’t want to setup a bunch of interdependent assets quite yet as I’m sort of trying to ensure I can implement most of the logic I had used with BGE bricks (or equivalent behavior). Understanding how to setup the animation logic will help greatly!

Here is what I wound up with. If TimeHeld is greater than 0.35 (time it takes to reach max position, tuned to specific animation time) Set Play Rate to 0. If Reset equals true set Play Rate back to 1.

[Edit]
Add a delay node after TimeHeld branch equals True with value of 0.01 to ensure Set Play Rate to 0 always executes after Set Play Rate to 1.

Indeed, I did run into a few timing issues at times with it not catching the pause at the right time. Completely lapsed on thinking of using a gate, much preferred. I’ve used them two or three times I’m simply not versed enough in the software. Much thanks for your assistance here is better tail on BP. :smiley:

Glad I could help!

Using Delays like that can let subtle timing issues sneak in. I’m not sure exactly what you’re going for, so the Delay may never be a problem, but I try to avoid using them that way regardless. Are you familiar with the Gate node? You can have the Play Rate 1 branch open or close the gate in front of Play Rate 0. That may or may not help you solve the problem you added the delay to fix.