Invalid set index 'position (on base: 'Area2D (ScriptName.gd)') with value of type 'Vector2'

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

Hi,

I try to instanciate a scene “Bullet.tscn” with this code

extends Area2D

[...]

var bullet_scene = preload("res://Scenes/Bullet.tscn")

func _process(delta):

[...]

# Shoot

if Input.is_action_just_pressed("shoot"):
	var bullet_instance = bullet_scene.instance()
	bullet_instance.positon = $BulletPosition.global_position # the line that break
	get_parent().add_child(bullet_instance)

I use Godot 3.0.6 (mono), the BulletPosition is a Position2D and the scene have a Area2D as root. I read that the problem happen when the scene is not instantiate but I do instantiate it, so i’m a bit lost.

enter image description here

Thank’s

:bust_in_silhouette: Reply From: congbinh75
bullet_instance.positon = $BulletPosition.global_position # the line that break

I think the problem is that you typed “positon” instead of “position”.

Oh my god. How could I not saw that.
Thank’s a lot !

I think too much year of Intelisens use make me lost my sight for those detail in new environnement.

I’m ashamed a lot

Coldragon | 2018-12-09 13:48