[Bolt] Help with wait/coroutines?

Hello, I’ll try to keep it short. I’m trying to make an object “blink” in the game I’m working on and trying to figure out the best way to do this. I tried to do a Wait for (seconds) item but it throws an error saying that it only runs with a coroutine?

I guess since I’m new to this all, I don’t really know what a coroutine is or how to “initiate” one. Or, for that matter, is there a better way I could make this object blink?

I hope I asked this in the correct place, and thanks for the responses.

Are you using some kind of visual scripting framework?

You can just Google “Unity Coroutines” and learn all about them but I have no idea how they work with whatever visual scripting thing you’re using.

Select the green Update node and in the Graph Inspector window check the “Coroutine” checkbox.

10 Likes

It’s Bolt, owned and developed by Unity now: https://blogs.unity3d.com/2020/07/22/bolt-visual-scripting-is-now-included-in-all-unity-plans/

1 Like

Oh my god, I am so embarrassed that the solution was so simple. Thanks for the help!

2 Likes

I am so embarrassed that i can not understand how to solve it, Have you solved the problem of creating a coroutine?can you take a screenshot for me?Thanks a lot!!!
(BTW,i am a chinese so i am so poor in english)

Just check the box on the first block (On Start or On Update, or On button).

You will see two green arrows if successful.

8878665--1212843--upload_2023-3-15_16-45-58.png

I have done it. but it no longer runs after “wait for seconds” . is any wrong with this node?
8879916--1213140--upload_2023-3-16_10-6-11.png

I see you’re running SetActive - implying that you are deactivating the GameObject. Coroutines will not run on deactivated GameObjects.

But how can i achieve to destroy a gameobject after 2 seconds by visual scripting?

The destroy function accepts a delay parameter, you don’t need a coroutine for that.

In general though you’d just run the coroutine on an object that is not being deactivated.

oops! Thanks a lot!!! I have understood it now! But What do I need to do to enable it to destroy successfully and then continue to trigger the next step. 8882745--1213719--upload_2023-3-17_13-9-18.png

Thanks again!!!

Destroy should be the last node in the sequence. If you need for something to happen after, you can use a Custom Event to communicate with a different graph that is not on the destroyed GameObject.

There’s also OnDestroy flow starting event node.

Also, please create new threads for new issues that are not related to the originally posted message.

yeah!!! I have been researching this problem for more than 8 hours, thank you !!!

1 Like