Instantiate a player using visual scripting in Unity

If you are totally new, check out our post on Unity instantiate to understand more details. In this tutorial, we will instantiate a player object on to the scene using visual scripting.

I will be using Unity 2021.1.13 for this tutorial

Final output

Creating a flow graph

  1. Create a new empty object in the hierarchy window.
  2. Name it as instantiate_graph.
  3. Go to inspector window and click add component.
  4. Add a Script machine component.
  5. Click new to create a new graph.
  6. Name it as instantiate_example.

Creating the logic

We are going to instantiate a prefab called my_prefab after 5 seconds of game start.

Free Unity asset banner

  1. Add a timer unit, get rotation and an instantiate gameobject node.
  2. set the timer duration to 5 seconds.
  3. Connect start event to timer start, time completed to instantiate.
  4. Set the game object to my_prefab in the instantiate node.
  5. Get the rotation of this gameobject using get rotation node and connect it as input to the instantiate node.
  6. You can change the position where you want the prefab to be instantiated in the instantiate node.

Top online courses in Development

Leave a Reply

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