Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Spatial
- func _process(_delta):
- #parent variables
- var Level_node = get_parent().get_parent()
- var Command_Camera = Level_node.get_child(1).get_child(0)
- var ray_origin = Vector3()
- var ray_target = Vector3()
- var mouse_position = get_viewport().get_mouse_position()
- ray_origin = Command_Camera.project_ray_origin(mouse_position)
- ray_target = ray_origin + Command_Camera.project_ray_normal(mouse_position) * 1000
- var space_state = get_world().direct_space_state
- var intersection = space_state.intersect_ray(ray_origin, ray_target)
- var Projected_cursor = Level_node.get_child(1).get_child(2)
- var Cursor_3D = Level_node.get_child(1).get_child(1)
- if Input.is_action_pressed("Mouse_left"):
- if not intersection.empty():
- var pos = intersection.position
- Projected_cursor.translation = Vector3(pos.x,pos.y,pos.z)
- if Projected_cursor.translation.distance_to(translation) < 0:
- Projected_cursor.translation.distance_to(translation) * -1
- if Projected_cursor.translation.distance_to(translation) < 1:
- Cursor_3D.translation = translation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement