Godot Version
Godot 4.2.1 Stable
Question
I have a simply bullet system with PhysicsRayQueryParameters3D. My bullet is directly spawning at collision point. But, I want to move the bullet by a speed to collision point and stop it.
(bullet isn’t real)
Here is the code:
func _bullet():
var c = get_node(cam) # camera node
var center = c.get_viewport().get_size()/2
var origin = $ray_begin.global_position
var ray_end = origin + c.project_ray_normal(center) * bullet_range
var ray_query = PhysicsRayQueryParameters3D.create(origin, ray_end)
ray_query.exclude = [self]
var ray = get_world_3d().direct_space_state.intersect_ray(ray_query)
if ray.is_empty():
pass
else:
DebugGeometry.draw_debug_sphere(10,ray.position, 8, 4, 0.1, Color.ORANGE_RED)
_debug(origin, ray_end)
func _debug(_p1, _p2):
DebugGeometry.draw_debug_line(10, _p1, _p2, 0.008, Color.GREEN_YELLOW)
“_bullet()” is calling when pressing the button.
Sorry for my English.