How to create a countdown timer using visual scripting in Unity

In our Unity timer post, we had discussed about creating various types of timers in Unity with C# code. In this tutorial, we will see how to create a countdown timer using visual scripting in Unity and display the timer on to the game scene.

Creating the game objects

  1. Add an empty gameobject called timer.
  2. Add a text gameobject. This will add a canvas and event system to your scene.
  3. Add a script machine component to the timer gameobject and create a new flow graph.
  4. Let’s called the flow graph timer_graph.
  5. Add a variable of type gameobject to timer and drag and drop your text gameobject to it. Name it Timer_display.

Creating the graph logic

  1. Add a timer, get variable, float to string and a set text block.
  2. There are many types of float to string block. Add the one with format option.
  3. Set the duration for the timer.
  4. Set the format you want in the float to sting block.
  5. Select the variable timer_display in the get variable block.
  6. Connect the graph as shown in the image below.
Flow graph for creating a countdown timer.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from VionixStudio

Subscribe now to keep reading and get access to the full archive.

Continue reading