The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

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)
Godot version 3.2.3
in Engine by (15 points)

1 Answer

0 votes
Best answer

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

by (6,942 points)
selected by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.