0 votes

.obj loads but no texture

func _ready():
    meshInstance = MeshInstance.new()
    var mesh = load("res://assets/model.obj")
    meshInstance.set_mesh(mesh)
    add_child(meshInstance)

in the tutorial .dae and .gltf are loaded through an editor (not a gdscript)

what format to use in gdscript?

Godot version 3.4.4
in Engine by (20 points)

1 Answer

0 votes
Best answer

I used to use .obj for my static model, but I dropped it sometime in 2021. I use GLTF now for all my models, both static and animated. It's much better (and better supported) than all the others. I highly recommend it above all the other model formats. It is lacking in only one area I've found (it doesn't handle Blender's face maps), but it is otherwise far and away the best format supported by Godot.

With that pitch out of the way, the .obj texture file and the texture itself must be in the same directory as the .obj file itself. It can be a real pain to manage .obj files, so you'll be doing yourself a favor by dropping it in favor of GLTF, as its textures can be embedded into the file itself.

by (339 points)
selected by

is it possible to load .GLTF from a gdscript?
advise an example

I always create a separate scene for each mesh, then I load that scene:

For 3.x:

var m = load("scene.tscn").instance()
add_child(m)

For 4:

var m = load("scene.tscn").instantiate()
add_child(m)

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]odotengine.org with your username.