RayCast2D not shooting missile when I jump

extends Node2D

@onready var ray_cast = $RayCast2D
@onready var timer = $Timer
@export var ammo : PackedScene

var player

func _ready():
	player = get_parent().find_child("CharacterBody2D")

func _physics_process(_delta):

func _aim():
	ray_cast.target_position = to_local(player.position)

func _check_player_collision():
	if ray_cast.get_collider() == player and timer.is_stopped():
	elif ray_cast.get_collider() != player and not timer.is_stopped():

func _on_timer_timeout():

func _shoot():
	var missile = ammo.instantiate()
	missile.position = position
	missile.direction = (ray_cast.target_position).normalized()

Hi All, first time posting, month lurker. I’m in the process of creating a game where the goal is to dodge missiles. I’m up to the point where I have player movement and the turret shoots at the player, which I am using a RayCast2D to track player movement. However I noticed that whenever I jump, the raycast breifly disappears and then reappears. This inturn causes the missile not to shoot at the player. Only when I am back on the ground does it begin shooting again.

My goal is to have the missile launch toward wherever the player is, even in the air. I noticed also that if the wait time on the timer is set to .25 this isnt an issue and but still kinda weird.

If anyone could help me solve this issue I would much appreciate it.

Youtube link to for visual aid of issue.

Closing this first post out, was able to fix this issue early on. Also my first time posting here on the forums, little lost :smiley:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.