Holding Breath While holding Mouse 1

I created a blueprint where when the player is holding down Left Mouse Button it takes away his breath.

Now when I hould Left Mouse Button I expect it to go down to 0, why is it goin to 10 inbetween tho?

2

If you completely disconnect Tick above, do you have anything printed on the Screen?

2 Likes

Timeline is looped. To optimize you could turn the timeline off when it hits max / min values

2 Likes

It looks like there must be another print string somewhere in code that prints the number 10 value on each tick as well (10 being the max value I assume)
I tried to reproduce your code, and it works without problems.
Try to find all references to Max in your blueprint(s) to see, if it is printed anywhere.

2 Likes

whats inside the timeline?

Nothing. Its a less heavy replacment for tick that can be stopped at will.
The only internal parameter that is set is that it is looped.

2 Likes

Great, that you did solve the problem. Just some thought:

If your actor is ticking anyway, why not use the tick? It does work without a timeline as well, because the timeline update pin just fires to update on every tick. So this one works as well without an extra timeline, also with the delay to set some interval.

A Gate node comes in if you would like to keep the tick from processing this one if 0 or max has been reached:

If the actor is not ticking normally, you can also use the Set Actor Tick Enabled node to switch ticking on/off.

BTW: just curious, did you find, where the additional print 10 did come from?

2 Likes

Tick is every frame. The heavier the tick the more cycles of cpu will be wasted that could be used elsewhere. It adds up with time. Even epic games treats it like it’s the plague :P. It only is needed in some situations but shouldn’t be the go to method.

2 Likes

No haven’t found it, I deleted the Print, but there was nothing printing after that.
So it had to come from there i dont’t know

So this is basically my full Blueprint now, I play a sound breathing in when Mouse Button is clicked. Then the Camera fades away (Blackscreen), Breath gets decreased.
Goes the other way with releasing and breathing out.

When breath goes to Zero player dies.

1 Like

Yes, sure, tick is every frame - but so is Timeline Update as well. So, if a character is ticking anyway, why not using that tick to do the processing instead of launching an empty timeline just to ‘simulate’ tick? In both cases, of course the processing should be reduced to a minimum.

1 Like

A lot of people go in depth why to avoid it. Epic themselves mentioned during a livestream that they avoid it in fortnight. Only place where you can even consider it is pure c++ and sparingly.

1 Like