Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | abelgutierrez99 |
I just added CollsionShape
and Area
to the voxels (3D tiles) of my games. I create the Area
with generate_faces
and create a signal to dectec de mouse_detect_area
:
func generate_faces():
var surfaceTool : SurfaceTool
surfaceTool = SurfaceTool.new()
surfaceTool.begin(Mesh.PRIMITIVE_TRIANGLES)
for i in range(VOXELDATA.voxelFaces.size()):
if notNeig[i]:
for j in range(VOXELDATA.voxelFaces[i].size()):
surfaceTool.add_vertex(VOXELDATA.voxelVertices[VOXELDATA.voxelFaces[i][j]])
surfaceTool.generate_normals()
mesh = surfaceTool.commit()
meshInstance.mesh = mesh
bodyShape = mesh.create_trimesh_shape()
collisionShapeBody.shape = bodyShape
add_child(collisionShapeBody)
areaShape = mesh.create_trimesh_shape()
collisionShapeArea.shape = areaShape
area.add_child(collisionShapeArea)
add_child(area)
area.connect("input_event", self, "_detect_area") # self is the StaticBody that contain the Area
func _detect_area():
print("Collision detected")
Although CollisionShape
and Area
are created in the same way, CollisionShape
are working, since I tested with a falling RidigBody
; but Area
is not, nothing appears in the Debugger when I click the voxels. I add an image with the scene and the scene tree: here
I tried to move the ´Area´ outside the chunk using Remote option to chech if there was some problem, but it is still not working.