Can Area3D detect Raycast3D?

Godot Version

4.7.2

Question

As title suggested, can I detect with Area3D the Raycast3D enter?

I’m currently making this automated path3d “fake player”, with enemy going around and casting fireballs at it, but for my Area3D(shield) it not detecting it as only available types are :

current remote scene during gameplay is, the Fireball is what suppose to be detected. Should I Reparent it to something else to be able detect it hit different parts of player[Area3D]/Colliders?

current script for fireball

extends RayCast3D

@export var speed := 50.0
@export var explosion_scene: PackedScene
#@export var decal_scene: PackedScene	
@onready var audio_stream_player_3d: AudioStreamPlayer3D = $AudioStreamPlayer3D

func _ready() -> void:
	audio_stream_player_3d.play()

func _physics_process(delta: float) -> void:
	global_position += global_basis * Vector3.FORWARD * delta * speed
	target_position = Vector3.FORWARD * delta * speed
	force_raycast_update()
	var collider = get_collider()
	if is_colliding():
		if collider.has_method("take_damage"):
			collider.take_damage(5.0)
		audio_stream_player_3d.stop()
		var point := get_collision_point()
		var normal := get_collision_normal() 
		var rotate_up := Quaternion(Vector3.UP, normal) # gertenko magic

		var explosion := explosion_scene.instantiate()
		#var decal := decal_scene.instantiate()
		explosion.position = point
		#decal.position = point
		#decal.quaternion = rotate_up # gertenko magic

		get_tree().current_scene.add_child(explosion)
		#get_tree().current_scene.add_child(decal)
		explosion.blast()
		queue_free()
			
func cleanup() -> void:
	queue_free()

scene

No, but raycast can detect the area.

added signals from Fireball using new Area3D

func _on_area_3d_area_entered(area: Area3D) -> void:
	print(area)

func _on_area_3d_area_shape_entered(area_rid: RID, area: Area3D, area_shape_index: int, local_shape_index: int) -> void:
	print(area)

func _on_area_3d_body_entered(body: Node3D) -> void:
	print(body)

is there way to directly handle it from Raycast3D script or adding Area3D be better?

Well you can connect area’s signal to wherever is more convenient to handle them.

I found it cause not being detected at all the time, as speed of fireball.

	if is_colliding():
		var collider = get_collider()
		if collider.has_method("take_damage"):
			collider.take_damage()
		if collider.has_method("hit_shield"):
			collider.hit_shield()

This seems to worked better, but required to make script for shield as well, but not much trouble.

( ok I noticed there is issue with this check for method, even I if shield was hit it still returns as take_damage and not shield)

Video show the one with signals:

ok this setting solved it :slight_smile: