Godot Version
4
Question
I need help with my code, I’m very new to coding and I’m having issues with my Marker2D and Global position code on line 25. Whenever I play the debug and I hit the enter key it crashes and I get an error "Invaild set index ‘position’ (on base: ‘Node’) with value of type ‘Vector2’ ". I have no idea what this means and I’m trying to figure it out Heeeeeelp! (I was following this tutorial and got stuck around 4:00 - 4:30 https://www.youtube.com/watch?v=2G41KECXXn4&t=421s)
extends CharacterBody2D
const bulletpath = preload('res://Bullet.tscn')
func _ready():
pass
func _process(_delta):
if Input.is_action_just_pressed("ui_accept"):
print("pew pew!")
shoot()
#bullet function needs to be looked at for shooting a bullet - Godot Tutorial go to timestamp: 3:52
func shoot():
var bullet = bulletpath.instantiate()
get_parent().add_child(bullet)
bullet.position = $Marker2D.global_position