invalid call. nonexistent function "insatnce"

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

my bullet are not Appearing

in my screen this mensage appear:
invalid call. nonexisted function “instance” in base GDscript

here is the script

const pre_tiro = preload(“res://”)

func _physics_process(delta):

if Input. is_action_just_pressed("shoot"):
	 var bullet = pre_tiro.instance()                                                                                      
	 bullet.global_position = get_node("Position2D").get_global_position()         
:bust_in_silhouette: Reply From: exuin

Use new(), instance () is for packed scenes

Also you can’t set the global position before adding to scene tree, switch the last two lines

:bust_in_silhouette: Reply From: Ngong8
const pre_tiro = preload("res://")

The thing you declared here is a gdscript, not a scene that can instances nodes, so you will get nonexisted function instance error.

i didn’t saw that. it worked now

flinmer | 2021-03-05 23:47