Godot Version
4.4
Question
I’m trying to shapecast a sphere through a mesh to hit other meshes behind it from the camera. My X position of my target im trying to hit and the x target_position of my shapecast ray are correct, but the y and z are always massively off and I can never get the shapecast trigger it’s is_colliding
check.
I’m not sure how to procceed as even with visible collision shapes turned on in the debug menu, I can never see my shapecast.
For example hovering directly my fish I get this:
fish pos(-42.10647, -4.45757, -14.7431)
target pos(-42.20139, -540.6368, -747.0784)
The y and z are way off, if I’m hovering over it, it should line up right?
Here’s the code that produces that result:
func _process(delta: float) -> void:
var mouse_pos = get_viewport().get_mouse_position()
var ray_origin = current_camera.project_ray_origin(mouse_pos)
var ray_dir = current_camera.project_ray_normal(mouse_pos)
var max_distance = 1000.0
shapecast.target_position = ray_origin + ray_dir * max_distance
print(str("target pos", shapecast.target_position));
print(str("fish pos", position))
if shapecast.is_colliding():
print ("colliding with something")