Bullet (Arrow) Spwaning, but _ready and _process not running

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

I have this code. It worked in a prior attempt at this project. The projectile fired fine. Now it appears, but doesn’t move. My print() statement does not print on spawn (_ready).



func _process(delta):
	# Rotate with mouse
	var mousepos = get_local_mouse_position()
	rotation += mousepos.angle()
	#Listen for mouse click and shoot
	if 	Input.is_action_pressed("Click"):
		if $Timer.is_stopped(): 

func shoot():
	var a = arrow.instance()
	a.transform = $loadspot.global_transform


extends Area2D

var speed = 999
var target
var canhit = true

func _ready():
	print ("Arrow created: ", speed)

func _process(delta):
	position -= transform.y * speed * delta
	if position.y <= Globals.TOP:

How is the arrow reference set in the Player script? Are you sure it’s referencing the Arrow script you posted?

jgodfrey | 2022-02-09 01:22

It’s not and it wasn’t when it was working.
Player tree is:

 - Sprite
 - Position2D
 - CollisionShape2D
 - Timer

I changed the root Arrow node from an Area2D to a Node2D and made the Area2D part of its tree. Seemed to do the job.
Not sure why it was working on my first attempt and not here, though.

Reason I redid it: I had placed my main tscn in the autoloader and got hit with that double _ready() bug.

I guess I’m set now. But thianks!

thomdotcom | 2022-02-09 02:24