UE4 c++ Delay/Timer syntax

  Рет қаралды 11,546

Matthew Hennegan

Matthew Hennegan

Күн бұрын

How to set up the equivalent of a delay in c++ using the timer manager.
Copy paste syntax:
Declare timer handle:
FTimerHandle _loopTimerHandle;
Begin timer:
GetWorld()(point)GetTimerManager().SetTimer(_myTimerHandle, this, &AMyActor::MyFunctions, 5.f, false);
Note - using point as I can't use greater than or less than in description

Пікірлер: 17
@chicoSemCerebro
@chicoSemCerebro 8 жыл бұрын
The audio was bad but still very helpful! Thanks!
@matthewhennegan839
@matthewhennegan839 8 жыл бұрын
Yeah sorry about that, I only realized after I'd recorded a few of these that the recording program was set to use the inbuilt mic, not the headphone mic -.- But glad you found the content useful, thanks for taking the time to comment!
@rafikrizik4722
@rafikrizik4722 7 жыл бұрын
I got it to work your way, but I want to call the delay from another method. This method is called in blueprint through event tick. Basically its a simple if statement checking if im in range, then I want it to call a method that prints "Attack" every second. So I have the timer in that if statement and it never prints the message. I verified that I do in fact reach that part of the code. Basically it seems like if I dont call it in BeingPlay() it never gets called.
@matthewhennegan839
@matthewhennegan839 7 жыл бұрын
I can't say for sure without seeing the code, but from the sounds of it it's not that it only works if called from OnBeginPlay() - it's that it won't work on tick because you're restarting the delay every single frame. You shouldn't really call delays from on tick - even in blueprint. If you have to do it that way, you should be able to get the state of the timer using the handle, there should be an 'IsTimerActive' or something along those lines you can check before re-calling it. But I'd have a look at your structure and see if that's where you should be calling the delay from.
@Jonathanlambert-art
@Jonathanlambert-art 8 жыл бұрын
Thanks, that was very helpful.
@matthewhennegan839
@matthewhennegan839 8 жыл бұрын
Jonathan Lambert glad it helped!
@ue4gamedev960
@ue4gamedev960 8 жыл бұрын
and ,why need two "settimer" functions in the different places?
@matthewhennegan839
@matthewhennegan839 8 жыл бұрын
+ue4gamedev That's just to make the loop, you don't need to have it in two separate places, but to fire off a loop on begin play, you use it to trigger the loop initially, then you use it again within itself to make that loop indefinitely.
@ue4gamedev960
@ue4gamedev960 8 жыл бұрын
+Matthew Hennegan Thanks for your answer.But I find other function in the documentation like "UPrimitiveComponent::BeginComponentOverlap( const FOverlapInfo & OtherOverlap, bool bDoNotifies)", but it seems to us that no useful,IF I want to deal with the collision ,the delegate is the only one way?
@adiladilov8655
@adiladilov8655 2 жыл бұрын
Thank you man! Only after this video i understood how timer works
@the_dark_jumper2211
@the_dark_jumper2211 6 жыл бұрын
Sorry for bumping an old video, but this was probably the most helpful tutorial I could find so far... So...I have a for loop within another for loop and i need the second one to have a delay on its end...so basically something like this: for(int32 i=0; i
@matthewhennegan839
@matthewhennegan839 6 жыл бұрын
In short - i've never found a clean way to do it. You can't put a time delay inside a for loop, it breaks how the for loop is mean to work. You do have a do a hack around one way or another. You can do it with timers with the syntax in this video, or just manually make them yourself by counting time every 'on tick' with delta time and looking for if it's gone past the timer value, but either way you will need your own manual counters and just watch for when the 'loops' should cancel manually. I agree it is dirty, but I never found a clean way to do that either.
@СчастливыйЧеловек-х9с
@СчастливыйЧеловек-х9с 3 жыл бұрын
make the font even smaller, you can...
@ue4gamedev960
@ue4gamedev960 8 жыл бұрын
I see you just declare the FtimeHandle "_looptimerHandle",but you don not initialize it.how did it work?
@matthewhennegan839
@matthewhennegan839 8 жыл бұрын
+ue4gamedev It'll be being set up within the timer manager itself. You only need to declare it so that you can use it. Think of the timer handle as a tag for that specific timer, it lets you talk to the timer manager about that specific one.
@kunaltomar131289
@kunaltomar131289 8 жыл бұрын
thanks for the video :)
@matthewhennegan839
@matthewhennegan839 8 жыл бұрын
+kunal tomar You're very welcome! Glad you found it useful.
UE4 c++ Event Dispatchers syntax
10:56
Matthew Hennegan
Рет қаралды 28 М.
UE4 C++ Tutorial - Timers - UE4 / Unreal Engine 4 Intro to C++
8:16
Ozoda - Lada ( Official Music Video 2024 )
06:07
Ozoda
Рет қаралды 17 МЛН
Do you choose Inside Out 2 or The Amazing World of Gumball? 🤔
00:19
哈哈大家为了进去也是想尽办法!#火影忍者 #佐助 #家庭
00:33
Unreal C++ Tutorial | How to make a Door
16:16
Sugimura Kaito
Рет қаралды 6 М.
UE4 c++ OnComponentOverlap and OnComponentHit syntax
10:23
Matthew Hennegan
Рет қаралды 13 М.
Dear Unity Devs C++ is NOT that Hard
8:33
The Game Dev Cave
Рет қаралды 38 М.
UE4 Custom CharacterMovementComponent - C++
36:28
SabreDartStudios
Рет қаралды 18 М.
Unreal Engine 4 C++ Tutorial: Line Trace on Tick
10:33
Harrison McGuire
Рет қаралды 10 М.
Enums in UE4 c++
9:02
Matthew Hennegan
Рет қаралды 12 М.
Unreal Engine C++ Guide - Forward Declarations
9:49
Mike Stevanovic
Рет қаралды 2,9 М.
If You Can't Make Games After This Video, Give Up
4:37
Fredyy
Рет қаралды 939 М.
Learn Unreal Engine Networking in 30 Minutes
27:25
reubs
Рет қаралды 103 М.