Invalid set index 'velocityy' (on base: 'node2d') with value of type 'vector2'

Godot Version

v4.2.1

Question

i try to create an airplane shooting bullet at my mouse direction, i try to fix the issue but i clueless, Any help would be appreciated. Attached image is script for the main code.
here is the code for the bullet script:
extends CharacterBody2D

var speed = 300
var velocityy = Vector2(0,1)

func _physics_process(delta):
var collision_info = move_and_collide(velocityy.normalized() * delta * speed)

thing is, do you have velocityy property/variable in bullet scene?

Ya i set it. Here is the code for bullet scripts:

extends CharacterBody2D

var speed = 300
var velocityy = Vector2(0,1)

func _physics_process(delta):
var collision_info = move_and_collide(velocityy.normalized() * delta * speed)

the bullet does looks like a Node2D, but somehow you refer it as a CharacterBody2D on script, what’s your scene tree for bullet looks like

Same like main but without child node2d, marker and camera.

then just

 bullet.get_child(0).velocityy= get_global_mouse_position().normalized()- bullet.get_child(0).position

will do
because it looks like your script is attached to the CharacterBody2D of the bullet scene you have, but the CharacterBody2D is the child of the scene node, so you will need to get it like that

1 Like

thx a lot for the info.