Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | anthony63 |
Hello, i am trying to set a mesh to a MeshInstance3D on godot 4.0 but it is giving this error
_ready: Required virtual method Mesh::_get_surface_count must be overridden before calling. <C++ Source> scene/resources/mesh.h:62 @ _gdvirtual__get_surface_count_call() _ready: Required virtual method Mesh::_get_blend_shape_count must be overridden before calling. <C++ Source> scene/resources/mesh.h:72 @ _gdvirtual__get_blend_shape_count_call() _ready: Condition "!static_body" is true. <C++ Source> scene/3d/mesh_instance_3d.cpp:241 @ create_trimesh_collision()
This is the source code
func update():
if mesh_instance != null:
mesh_instance.call_deferred("queue_free")
mesh_instance = null
mesh = Mesh.new()
mesh_instance = MeshInstance3D.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
for x in Globals.CHUNK_SIZE.x:
for y in Globals.CHUNK_SIZE.y:
for z in Globals.CHUNK_SIZE.z:
create_block(x, y, z)
st.generate_normals(false)
st.set_material(material)
st.commit(mesh)
mesh_instance.set_mesh(mesh)
add_child(mesh_instance)
mesh_instance.create_trimesh_collision()