Troubl using a scene as mesh

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By scolllly93

Hey, guys. I’m trying to use a scene as a mesh from code for the Meshintance of a KB when running the game but nothing appears.
The funny part is when using CubeMesh the Cube appears on the screen.
Any ideas?

func _ready():

	
sprite = MeshInstance.new()
var mesh = load("res://assets/asset_test.tscn").instance()
# var mesh = CubeMesh.new()  THIS WORKS
sprite.set_mesh(mesh)


var material = SpatialMaterial.new();
material.albedo_color = Color.red

sprite.set_surface_material(0,material)

sprite.name = "Sprite"
add_child(sprite)
:bust_in_silhouette: Reply From: Wakatta

Simply put Mesh and PackedScene Resource are not compatible

External mesh types are of file extensions .obj, .tres, .mesh, .res

And compatible types are of CubeMesh, ArrayMesh, PrismMesh, QuadMesh, CylinderMesh, SphereMesh, CapsuleMesh, PointMesh, PlaneMesh

Basically if it doesn’t end with Mesh it won’t mesh with MeshInstance.mesh

The only way to achieve what you want is to dabble with ViewportTextures

Thanks! Now I know what I was doing wrong :smiley:

scolllly93 | 2021-04-02 15:18