Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | AmagicalFishy |
This code is pretty straightforward; itsets a cell on the map:
func set_cell(coord, y=0):
var hexBody = StaticBody.new()
var hexCollisionShape = CollisionShape.new()
var hexMesh = MeshInstance.new()
hexCollisionShape.shape = hexCollisionResource.instance() # Preloaded earlier in the file
hexMesh.set_mesh(hexMeshResource) # Preloaded earlier in the file
hexMesh.set_translation(Vector3(coord.x, y, coord.z))
# Put it all together...
hexMesh.add_child(hexBody)
hexBody.add_child(hexCollisionShape)
hexBody.owner = hexMesh
hexCollisionShape.owner = hexMesh
# Connect to mouse signal
hexBody.input_capture_on_drag = true
hexBody.input_ray_pickable = true
hexBody.connect('input_event', self, '_highlight')
self.add_child(hexMesh)
func _highlight(event):
print('This tile has been clicked')
… yet nothing is printed out upon clicking around in the screen (after many tiles have been generated). I believe all of my settings are correct (I’ve checked my Project settings, and even though input_ray_pickable
is true by default, I set it to true just to make sure).
Am I doing something incorrectly?