Instance Objects with Visual Scripting

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PiloeGAO

Since few days,

I try to making a simple shooter game with only Visual Scripting.
But after many tries, i can’t achieve a basic instancing of my bullet (I use Node 2D).

I use Godot 3.1 (latest version from the official website).

thank you for your help!

:bust_in_silhouette: Reply From: vic.the.developer

Ok so you drag the Bullet.tscn from the Filesystem tab in, which creates a Preload of the bullet.

Then from Available nodes drag in Functions > Call, then set Call Mode to instance, set Base Type to PackedScene, set function to instance.

Connect your preload bullet node to the obj instance node.

Drag the node you wish to add the bullet instance to into your visual script editor from the Scene tab, holding down CTRL.

Get another Call node, this time set Call mode to Instance, Base Type to Node and function to add_child, then connect the Scene node you just added to the obj instance, and connect the return any from PackedScene.Instance() to obj node.

Heres what it should look like.