DoOnce not working properly

Hello,

I’m trying to do something very simple, only press a button with a controler to make the bouton move down and up.

The problem in VR is that the collision can be triggered multiple time very easily if for example the controler goes under the button then on the bouton again.
To not encounter this problem, I decided to use DoOnce with a short delay inside of the blueprint so the player have the time to move his hand back before it can be triggered again.

The blueprint so you can see better :

But it isn’t working as expected, when I trigger the button, it is triggered something like 10 times, the blueprint is executing the first timeline 10 times, waiting half a second on the delay, then doing the second timeline 10 times.
After these 10 executions, everything is working fine, I can press the button and it is executed only one time so I don’t understand why the first time it isn’t working.


As you can see the first time is triggered too many times but after the first time it is working well.

Have you debugged the Doonce with a Print?
'cause I don’t think it is the doonce, it might be the Location.

Hello,

I added some Print and you’re right it’s not the DoOnce it is the timeline :


The output I have is something like this :

Hello1
Hello2
Hello2
Hello2
Hello2
Hello2
Hello2
Hello2

And as usual after the first time it is normal again :

Hello1
Hello2
Hello1
Hello2

If I change from update to finished as the timeline output, it is acting almost normal but with a delay (I guess it is doing the timeline something like 30 times so there is a delay)

My timeline look like this :


I don’t understand why it is acting like this

I don’t know what the exact problem is, I used to get this also.

What you could Change:
Use the RelativeLocation instead of the World location, this way you don’t have to get the actor location and add it to something. So less stuff that could go wrong.
Just use the output of the timeline as location offset.

You should still be able to place the button wherever you want since it is the RelativeLocation.

'cause I’ve got nothing else to do at work, I made a Blueprint that should work the way you want it to.


I noticed that you use 2 timelines. You can just use one for pressing in and returning.

In the float track, simply change the float to your desired offset and the lenght to the timeframe you want the button to look pressed.
You could also remove the DoOnce since it is not really needed with the On begin overlap.

EDIT:
My bad, didn’t try it before posting.
This works just fine for me.

The update command of the timeline executes every tick. Make sure to use it and finished output properly, this will also will help you get rid of the delay nodes, currently you have multiple issues in the execution flow.
To visualise the execution flow add a break point (documentation will help here as well) on the do once node and step through the process to see what is going on.
Consult the documentation for how the timeline node works. Timelines | Unreal Engine Documentation

@Rukasu : I have no idea why but the relative location seem to be 0,0,0 in the world, so when I press the button it basically goes to 0,0,0 (and if I use tick it does from the start of the game). Also I still have the same problem except I have it everytime because of using Play from start instead of Play. Thank you for taking time to help though.

@AtsK : I already tried the break point but didn’t learn much with it, it looked like the DoOnce wasn’t stopping executions but it was instead the timeline who was executed too many times (from the print). I didn’t learn much from the documentation either about my problem.

But today I finally found a solution, the first time I press the button it is executed 30 times so I decided to try to set the play rate to 30 and since the problem appear only the first time I press the button, I only have to set it once at the beggining of the game :


I didn’t change anything else from the first post, this seem to work perfectly, thanks for your help :slight_smile:

You can test to create a custom event, dont put code like once and delays in the trigger wire, I remeber have problems too. And is more “logic” use a gate imo.

Okay so the fix I found is not a true fix, I don’t know exactly what is happening but when I set the Play Rate to 30, it is doing the movement way too fast (but at least it is done only one time)
I didn’t realise for the button because it is a small movement but I did a timeline for the slide of a door and I have the same issue as the first post, so I tried to set the play rate at 30 but the movement is done too fast :

On this movement if I don’t change the play rate, instead of moving to -10, it is moving to -300 (I didn’t count but it’s something close) but still in 10s like I set at first.

If I change the play rate to 30, the beggining of the movement is done correctly but instead of stopping smoothly at -10 it stop net, like it still want to do the movement to -300 but is stopped before.

I came across this : Timeline Issue - Blueprint - Epic Developer Community Forums

It is exactly the same problem I have, but his fix to add a tick doesn’t work at all for me, I think the timeline is broken, I don’t think it’s from my code because I did something as basic as that :

And I still have the same problem.

Is there a way to do a smooth movement without a timeline ?

What is the problem with your last “basic” blueprint?

Try this with your original blueprint:

  • Delete the delay node
  • Connect the Finished (not update) output of the first timeline to the Play input of the second timeline.

This is not the optimal way to do it, but should (hopefully) work.

To use relative location, the mesh can’t be the root component (and thus never “self”). The correct node is SetRelativeLocation.

SetActorRelativeLocation is for child actors position relative to their parent.

If I use the Finished instead of the Update the button is pressed only after a little delay and the movement is not correct.

I tried everything, I don’t know what to do anymore, if the actor I want to move is outside of the blueprint, there is no problem, if the actor is itself, the first time it is triggered the timeline doesnt work as expected (but after is fine as usual)

I’m 95% sure this is the timeline, I tried every set/add location and none of them seem to change anything.

I think I will post this problem on the blueprint section since it’s not related to VR at all.

EDIT :

I just discovered that it is related to the frames per second, I tried to explain my problem better from the start here : Timeline broken when using movement to self ? - Blueprint - Epic Developer Community Forums