Download

Python - how do i fix "missing required argument 'type'"

Error message:

LogPython: Error:     mesh.create_mesh_section(0, verts, triangles, normals, UV, unreal.Array(), tangents, False)
LogPython: Error: TypeError: call() missing required argument 'type' (pos 1)

My Code:

xLength = 10
yLength = 10

spacing = 100

verts = unreal.Array(unreal.Vector)
UV = unreal.Array(unreal.Vector2D)

for x in range(0, xLength):
    for y in range(0, yLength):
        
        # add vertices
        verts.append(unreal.Vector(x*spacing, y*spacing, 0))

        # add UV's
        UV.append(unreal.Vector2D(x / xLength, y / yLength))
        
# Calculate triangles
triangles = unreal.ProceduralMeshLibrary.create_grid_mesh_triangles(xLength + 1, yLength + 1, False)

# Calculate tangents and normals
normals, tangents = unreal.ProceduralMeshLibrary.calculate_tangents_for_mesh(verts, triangles, UV)

mesh = unreal.ProceduralMeshComponent()

mesh.create_mesh_section(0, verts, triangles, normals, UV, unreal.Array(), tangents, False)
# where the error is  -     ^^^^^

The error is actually referring to the ‘vertex_colors’ argument. Looks like you need to specify the data type for the array:

unreal.Array(unreal.Color)