Thanks
But if there are many objects, how to find out which one was clicked ?
var spheres = [
{"x": 1,"y": 1,"z": 1},
{"x":-1,"y": 1,"z": 1},
{"x": 1,"y":-1,"z": 1},
]
func _ready():
for s in spheres:
addCSG(s)
func addCSG(s):
var cs = CollisionShape.new()
cs.shape = SphereShape.new()
var a = Area.new()
a.add_child(cs)
a.connect("input_event", self, "_on_Area_input_event")
var csg = CSGSphere.new()
csg.transform.origin = Vector3(s.x, s.y, s.z)
csg.add_child(a)
add_child(csg)
func _on_Area_input_event(camera, event, position, normal, shape_idx):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and event.pressed == true:
print(position, shape_idx)
- connect doesn't pass custom parameters
- emit_signal - how to bind to onclick ?