0

I have an .obj file which the model i want to add, which is stored at:

C:\Users\MTLS\source\python\Models_2-3D models\Triangular_Prism.obj

But when i try to load the model into the entity using this code:

spike_model = r'C:\Users\MTLS\source\python\Models_2-3D models\Triangular_Prism.obj'

class Spike(Entity):
    def __init__(self, position = (0, 0, 0)):
        super().__init__(
            model = spike_model, 
            texture = 'white_cube',
            collider= 'box', 
            color= color.red, 
            scale= (1, 1, 1), 
            position= position
        )

spike = Spike()

The entity is only loaded as an invisible entity, i cant see it when i launch the program.

I have followed some tutorials on yt but non of them works

How can i fix this and make the entity become visible? Thanks.

nHyper
  • 53
  • 5
  • 1
    Does it work when you place the .obj file in the same folder as your Python script and simply load it by `Triangular_Prism.obj`? – Jan Wilamowski Jan 15 '22 at 11:02

1 Answers1

1

Use relative path, not absolute path. ursina assumes you want to distribute your game at some point and that your assets are in the same folder or below as the script. So the solution is to move the model into that folder.

It's also possible to use load_model(name, path) or modify application.asset_folder in order to load from a different folder, but keep in mind that will only work on your computer.

pokepetter
  • 1,383
  • 5
  • 8