Trigger an Action after some Time (Unity Tutorial)

preview_player
Показать описание
Let's see how we can trigger an Action after some time, extremely useful for cutscenes.

If you have any questions post them in the comments and I'll do my best to answer them.

See you next time!

#unitytutorial #unity3d #unity2d

--------------------------------------------------------------------

Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.

I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.

--------------------------------------------------------------------

Рекомендации по теме
Комментарии
Автор

I really like your modular works and try to do it my own way for my scripts! You inspire me, thank you.

TheKrckeR
Автор

This is very helpful. Thanks! I usually use coroutines too, but this seems to be much simpler. I might try this on my crops and avoid the day/night cycle. Thanks, again.

indieprogress
Автор

Extremely clever & useful piece of code. Thank you for this & all of your extremely helpful videos. You are a life saver.

scottblemaster
Автор

Fantastic, I've used this as a pause between turns for a roguelike movement so it gives a .3 pause before user can move again. Makes the movement feel much better.

slipknotsoad
Автор

Wow wow, I did calling functions triggert by time in such a weird way coparted to yours. I think now everything will be more understandable and also cleaner in my code. Thy @CodeMonkey as always you are teaching me new stuff to get my dream near to be a professional developer for Games or anything else. Big Heart for you!

luka__
Автор

Man, it is very nice to see your channel growing

raven
Автор

This is really cool. I did something SLIGHTLY different for the destroy thing. I just put my timer in a variable if I plan to kill it. Then I reference the variable and use the destroy functionality to kill it. Im hoping to avoid the for loop but I get how it could come in handy sometimes. Thanks for sharing this. :D Also, been watching you for over a year and even get your email newsletter but just realized I have not subscribed to your channel. Fixed that situation right now. haha. Thanks again for all the cool stuff you share!

KillerGameDev
Автор

Thanks You for the helpful video, perfect tutorials! :)

JanZbedny
Автор

Thank god i found my answer here<3 I was trying to do a trigger with IEnumerator but the problem is when trigger activates repeatedly it stacks, and I couldn't find way for reseting between triggers.
But with this i just did my own timer and with some bool it was so much simpler, i am just laughing all my wasted hours.

mertdemirhelboyz
Автор

Hey I love this tutorial I decided I was going to try to make this exact same thing my own way and then I was going to follow your tutorial, which I do with most of your tutorials. After I made mine and tallowed this tutorial I decided to take some things from this tutorial and add it to mine. the one main thing that mine has and yours does not is it will only insatiate one game object and then all of the Function timers subscribe to that one gameobject's OnUpdate function. I really like all the stuff that this tutorial has. Thank you!

theashbot
Автор

Thank you this video really helped me make a static class what makes a web call using the unity web request system (I prefer to use the HttpClient but that has no support for downloading a audio file). also did you know about the "await // This waits 1 second"? that is what I personally use for waiting a set amount of time.

theashbot
Автор

I'm use function timer in DoTween Asset's Sequence. it is really really comfortable

asdda
Автор

I am using Timer component. It uses Update () if MonoBechaviour. But there is also an option to use InvokeDelayed() - it is MonoBechaviour function.

dadlord
Автор

You can easier work with Invoke(action, time). That executes the action after the time. If you want to repeat this, you can use InvokeRepeat(action, time). This executes repeatly the action after time

christopherk
Автор

Many thanks for your excellent video. One questions ...

At 16:47, in LIne 21 of your code, would changing "FunctionTimer" to timerName break anything or have any drawbacks? This is only just to be able to distinguish amongst FunctionTimers in the Editor hierarchy. It seems to work ... (last magic words).

lgmontoyauk
Автор

First, thank you for your videos. This one is great, I use it all the time and it works.
My question is this … When we create initGameObject = new
This gameobject still remains in the hierarchy as a gameobject. Did I miss where you destroyed this object, or should I just leave it?
I did add it to DestroySelf()
Nothing bad has happened yet. Will it be problematic later? 

Again thank you for your videos, I enjoy your fast paced and your teaching.
Thank you
D

djdavidj
Автор

Is there any video on how to make factions or clans? And than choose what faction is enemy with other

ConchStreetStories
Автор

Can u make more like this ( ex: buy and upgrade character)
enjoying :b

devop
Автор

You need to swap lines 71, 72. Reason is you never remove timer from list after it was destroyed. It's destroyed before removed from list. Correct me if i was wrong. If you ever tested that static list.count it would show 2 instead of 1.

veteranxt
Автор

Hi, I am running into an issue here. I am using Unity 2021.2.7f1 and the latest version of Visual Studio Code. I am not able to test the FunctionTimer class, it does not work for any object I put it add it to (empty, main object which is a car, any other game object). I did the FunctionTimer and Testing classes exactly like you did. But when I start the game no logs can be seen in the console. I played with the time and made it 10f to see if it was becuase of loading time since I saw another person ran into that issue. How can I address this?

mustafamuhammedkanmaz