NeOleg
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.is_action_pressed("action_mouse_left"):
var space_state = get_world_3d().direct_space_state
var cam = $Camera3D
var mousepos = get_viewport().get_mouse_position()
var origin = cam.project_ray_origin(mousepos)
var end = origin + cam.project_ray_normal(mousepos) * RAY_LENGTH
var query = PhysicsRayQueryParameters3D.create(origin, end)
query.collide_with_areas = true
query.exclude = [self]
var intersect = space_state.intersect_ray(query)
if intersect:
print("interset click1: ", intersect)
intersect object
{
position: Vector3 # point in world space for collision
normal: Vector3 # normal in world space for collision
collider: Object # Object collided or null (if unassociated)
collider_id: ObjectID # Object it collided against
rid: RID # RID it collided against
shape: int # shape index of collider
metadata: Variant() # metadata of collider
}
works for me, all you need to do here is to check if the intersect.collider is in group somehting.. but i ratehr not use groups but classes. so to check i just use -
if intersext.collider is Player:
# Do this and other things, not because they are easy but because they are hard.