I have been using the code to project a raycast from the mouse
var mouse_pos = get_viewport().get_mouse_position()
var ray_length = 100
var from = camera.project_ray_origin(mouse_pos)
var to = from + camera.project_ray_normal(mouse_pos) * ray_length
var space = get_world_3d().direct_space_state
var ray_query = PhysicsRayQueryParameters3D.new()
ray_query.from = from
ray_query.to = to
ray_query.collide_with_areas = true
var raycast_result = space.intersect_ray(ray_query)

however I cannot figure out how to make use of the string it prints
{ "position": (-0.463872, 0, -3.119721), "normal": (0, 1, 0), "collider_id": 26927432863, "collider": StaticBody3D:<StaticBody3D#26927432863>, "shape": 0, "rid": RID(4071628996609) }
If anyone knows a solution that would be a a great help thanks

  • xyz replied to this.
  • The_Grass_man The returned value is not a string but a dictionary.
    To get the position:

    var position = raycast_result["position"]

    The_Grass_man The returned value is not a string but a dictionary.
    To get the position:

    var position = raycast_result["position"]