I’m completely new to UE and blueprint so I need a little hepl.
I want to start the timeline that i created by pressing “F” key. I do not know where I should pin on keyboard event.
When I set autoplay and loop in timeline node animation working good. The light goes out and lights up, but I want to have control over this by pressing “F” key.
Disable the auto-play and loop, then hook up the ‘Pressed’ on the input to the ‘Play’ on the timeline, do the same for input release and reverse. This will increase/decrease the intensity when you press and release F. If you want to be able to toggle the light by pressing F, hook up the ‘Pressed’ on the input to a ‘Flip Flop’ node, and hook up the ‘A’ to the ‘Play’, do the same thing for B and reverse.
why not setting a bool after you pressed F. F.e. its called bLightOn.
Start State is -> light is dark
Press F -> set bLightOn to true (or invert it with a NOT)
Play your timeline based on that bool -> so put branch with bLightOn value, if true Play Timeline if not Reverse Timeline,
if you dont want to toggle during a timeline loop then you could take your timeline variable and check if “Timeline->isPlaying” if yes, dont do something if not play regarding your bLightOn bool.
Yeah, you don’t need the branch. Connect pressed to play and released to reverse. Try simulating your game from the blueprint window - then you can see the executions in the blueprint.
It’s a bit strange that it’s not working. Are you holding down the f key? Does your timeline produce a float which ramps from 0 to an appropriate value? Have you set the keyframes in the timeline? Is the duration of your timeline too short or long? You should persevere! If you don’t you might give up on the engine.
in UE4, sometimes there are a multitude of ways to achieve the desired results, it’s just choosing which is right one for the situation.
to avoid holding down the F key:
set key input action to F in Input of Project Settings
create a custom event that fires the timeline
and I think a DoOnce node after you hit the F Key would work as well (probably what you really want)
you can also use a branch like you have & set a bool variable after the timeline runs, would make sure it ran all the way through before reversing or resetting
really new to UE4, barely a year in, loving all the community and available info. I thought I’d contribute to this. So I had the same lighting issue, basically trying to use the ui widget to trigger a light animation, you’d press a button and that would play a timeline and increase the point light intensity smoothly instead of an abrupt on/off. The way I did it:
UI Widget button causes boolean to go true/false let’s call it LightSwitch
Create an actor blueprint with said point light inside (this is simply because widgets don’t support timeline effects, othwerwise I would have just cast to the point light saving me a lot of time)
In the new actor blueprint follow the attached images
I had a lot of issues with getting this to work right. at first the animation didn’t reset so when it was triggered again it would just jump to the last frame doing the on/off thing again, after that I got it to reset but it would play continuously for every event tick check so I used a do once to only …well do it once… so that worked but it couldn’t do it again until I reset the do once and I couldn’t reset it when it finished or else it would go in a loop again, so I’m cross-reseting.
After each animation is finished it does a sequence in which it firsts resets the do once for opposite animation prepping it for when I hit the button and 2nd sets the new time to 0 for the opposite animation.
The only problem you might have with this is it’s missing a “default state” of being off so when the game starts even though the button is not pressed, the boolean is off so it plays the off animation once. I bet there’s a way around this like doing a check for the number o presses on the button and only starting the checking process after the button has been pressed once, not when the game starts… but that’s for another time.
I know this is an old thread but this problem gave me some trouble and I thought someone else might benefit from this possible solution.