Modified code a little bit - using 3 methods of raycasting - programmatic raycast, Raycast3D node and on_body_entered signal. Still no reliable result - sometimes works as expected, sometimes - grenade flies forward, hits the wall and just flies back, nothing reported by all the checks
func _physics_process(delta):
var query = PhysicsRayQueryParameters3D.create(position, to_global(Vector3.FORWARD))
var from_ray = get_world_3d().direct_space_state.intersect_ray(query)
if from_ray:
print("from_ray " + str(from_ray["collider_id"]))
Events.explosion.emit(global_position, from_ray["collider"])
destroy()
elif raycast.is_colliding():
print("from_ray " + str(from_ray["collider_id"]))
Events.explosion.emit(raycast.get_collision_point(), raycast.get_collider())
destroy()
func _on_body_entered(body):
Events.explosion.emit(global_position, body)
destroy()
pass
Here's grenade scene configuration, maybe I'm doing smth wrong in it?