Starting 'timeline' by keyboard event

Hi there,

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.

Any help would be fantastic

Cheers,

Arek

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.

Thanks for reply.

I did as you wrote, but it still is not working. See screenshot

I tried also with ‘Flip Flop’ node, but that did not work.

Also I switch off and switched on the light visibility in rendering tab.

Any other idea?
thanks in advance

Hey,

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.

cheers

I expect input is disabled on your blueprint. Go to class defaults I think and change player input from disabled to player 0

You’re right !! But it still does not start the timeline, only light turns off when it is set on in the visibility.

I do not know if I understood you well. I created something like this,

764ce88e6cb2a0f52ba0ed39a7162a7683b622a5.jpeg

but also it does not work. Probably I am doing something wrong.

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.

I also tried this, but it still does not work. I don’t know why.

I think I’ll do it using matinee. I found some tutorials on how to make a similar effect.

Anyway thank you very much for your help.

cheers

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.

It’s working !! Unnecessarily let go of the “F” key. I Should keep him down for the entire timeline.

Thank You for your help !!

Best wishes

hi, this will get easier! lol

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:

  1. set key input action to F in Input of Project Settings
  2. create a custom event that fires the timeline
  3. and I think a DoOnce node after you hit the F Key would work as well (probably what you really want)
  4. 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

some of your options :wink:

I think I solved it!

Hi all,

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:

  1. UI Widget button causes boolean to go true/false let’s call it LightSwitch
  2. 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)
  3. 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.

Best of luck!
Alex