Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ursina Engine textures

Tags:

python

ursina

So I started playing with an API for python called Ursina Engine and I got to the point I need to add a texture. Whatever I put for the file path, always just doesn't render. No errors, just a blank entity.

    from ursina import * # import everything we need with one line.
#an entity is basically anything you can see or hear/interact on a screen

def update():#updtes every frame
    if held_keys['a']:
        test_square.x -= 1 * time.dt #so the .x is the axis (you can use y too and -= minuses every frame), multiplying it by time.delta means it will move in accordance with the framerate
    # time.dt is the completion time between the last frame
    if held_keys['d']:
        test_square.x += 1 * time.dt
app = Ursina()

test_square = Entity(model = 'quad', color = color.red, scale = (1,4), position = (3,1))#x then y for scale and pos

sans_texture = load_texture('sans.png')
sand = Entity(model = 'quad', texture = sans_texture)

app.run()   
like image 445
Anslip Avatar asked Oct 20 '25 13:10

Anslip


2 Answers

Your code should work but if it doesn't you probably haven't loaded the texture properly. If it's located in a file called 'textures' for example, your code should be something like this:

sans_texture = load_texture('textures/sans.png')
sand = Entity(model = 'quad', texture = sans_texture)

But if it still doesn't work, you can try this:

sand = Entity(model = 'quad', texture = 'textures/sans.png')

I Hope this is helpful.

like image 55
athrb Avatar answered Oct 23 '25 04:10

athrb


Probably the texture isn't loaded correctly, to load it correctly you can try to copy paste the image link, for example:

sand = Entity(model = 'quad', texture = 'C:/Users/guest/Pictures/sans.png')
like image 30
TheGuyWhoLikesUrsina Avatar answered Oct 23 '25 02:10

TheGuyWhoLikesUrsina



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!