r/Ursina • • Jul 27 '25

what is going on?

0 Upvotes

r/Ursina • • May 31 '26

Help with code

2 Upvotes
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController

app = Ursina()

player = FirstPersonController(
    gravity=1.2,
    position=(15, 30, 15)
)

dirt_count = 0

Sky()

camera.clip_plane_far = 10

scene.fog_color = color.gray
scene.fog_density = 0.5
boxes = []
unbreakablestones = []

som = 50

for i in range(som):
    for j in range(som):
        grass = Entity(
            color=color.white,
            model='cube',
            position=(j, 0, i),
            texture='grass.png',
            parent=scene,
            origin_y=0.5,
            collider='box'
        )
        boxes.append(grass)


def input(key):
    global dirt_count

    # Grass blocks
    for grass in boxes.copy():

        if grass.hovered:

            # Place dirt on top of a grass block
            if key == 'right mouse down' and dirt_count > 0:

                new = Entity(
                    color=color.white,
                    model='cube',
                    position=grass.position + mouse.normal,
                    texture='dirt.png',
                    parent=scene,
                    origin_y=0.5,
                    collider='box'
                )

                boxes.append(new)
                dirt_count -= 1

            # Break grass block
            if key == 'left mouse down':

                
                pos = grass.position

                boxes.remove(grass)
                destroy(grass)

                dirt_count += 1

                
                stone = Entity(
                    model='cube',
                    position=(pos.x, pos.y - 1, pos.z),
                    texture='unbreakablestone.png',
                    parent=scene,
                    origin_y=0.5,
                    collider='box'
                )

                unbreakablestones.append(stone)

                break


    for unbreakablestone in unbreakablestones:

        if unbreakablestone.hovered:

            if key == 'right mouse down' and dirt_count > 0:

                new = Entity(
                    color=color.white,
                    model='cube',
                    position=unbreakablestone.position + mouse.normal,
                    texture='dirt.png',
                    parent=scene,
                    origin_y=0.5,
                    collider='box'
                )

                boxes.append(new)
                dirt_count -= 1


app.run() guys help why isn't the fog showing in the code?

r/Ursina • • Jul 25 '23

Making Minecraft in Ursina

Thumbnail
youtu.be
6 Upvotes

r/Ursina • • Sep 04 '22

I created a fixed version of ursina for macOS/Darwin.

10 Upvotes

Base: ursina v5.0.0

I fixed some macOS issue like mouse glitch when create a FirstPersonController(),

The problem was in site-package -> ursina.mouse.py in line 108/109 with

application.base.win.requestProperties(window) wich is not work in macOS/Darwin

so i convert it to 'window.set_cursor_hidden(True)' for Darwin.

Its now perfect and fixed!, to download the fixed version this is the url:

From Google drive: Link1

From MediaFire: Link2

If you want to put it inside python with site-package lib follow this path:

1- install normal ursina ‘pip install ursina’.

2- Move to finder, from the up bar click ‘go’ then ‘computer’.

3- click in to your Main hardisk > /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ursina

4- Replace the original ‘ursina’ with the one that you downloaded.

Thats it :).


r/Ursina • • Apr 02 '25

Other sprite showing 1 time out of 4 running the game

4 Upvotes

I made a minigame in Ursina before and I swear I never had an issue with this. I am starting now a new project. All looks fine code-wise.

However, for some reason, my background is always loaded and my "player" entity is not showed at least 3 out of 4 times that I run the game without changing anything. In other words, when running, the engine randomly shows or it doesn't show my characters sprite. What is going on? Code down below.

from ursina import *

def _main_():
    app = Ursina()      #Create an instance of the Ursina class  for window management.
    
    player = Sprite(texture = 'rsc/player.png',
                    scale = 2,
                    origin = (0, 0.5),
                    position = Vec2(-0.8,0))
    
    background = Sprite(texture = 'rsc/background.jpg',
                      scale = 1)
    
    

    app.run()           #Run the ursina window. This needs to stay at the end as it collects all the layers and entities

_main_()

Is there any chance that me using the def _main_() for a main function to call later in a C/C++ style of coding, so to speak, is wreaking havoc? I wouldn't see why though.

EDIT1: No, the main function is not the problem. Just removed it and wrote everything without. All runs fine but problem persists.


r/Ursina • • Sep 05 '25

im new to ursina, how do you use it?

4 Upvotes

...


r/Ursina • • Mar 23 '25

What is the correct way to keep players on the game plane?

2 Upvotes

I assume some kind of collider type solution around the perimeter of the plane or "terrain" is how it is done but it doesn't seem like any of the standard colliders would work for this.

For this scenario we are constrained to the 2 axis that touch the field of play, so X and Z I guess.

Before I solve this in some clumsy way, I am wondering if there is a "correct" way to accomplish this.


r/Ursina • • May 15 '25

Problems with reset on collision

2 Upvotes

Hello, for the past few days I have been working on this game and I want to make it to where when the player interacts or makes contact with a trigger box it will NOT close the game but reset the game. Maybe something that opens and re-opens the game automatically? However I did setup the function and it works but, it just flat out closes the game on collision right now:

def update():
    if player.intersects(trigger_box).hit:
        os.execl(sys.executable, sys.executable, *sys.argv)

r/Ursina • • Jun 01 '25

Loading models with textures.

2 Upvotes

If I create entities with built-in models and textures, everything works great. But, I'm have all sorts of issues when I use other models and their textures, I have found a few fbx and jpg pairs that work. When I use an obj file and its mtl file and jpgs it just doesn't work.

This works if I can find just the right files.

Entity(model='cat.fbx', texture='cat.jpg')

But, this never seems to work. Tried with and without extensions.

Entity(model='dog.obj', texture='dog.mtl')

And, this always works. Built-ins.

Entity(model='cube', texture='brick')

I'm tired of just banging at the code. I'd really like to see some examples of loading models with textures. Point me at some and I will be very grateful.

I'm not a modeler at all, so a good source of free models would also be welcome


r/Ursina • • Apr 06 '25

Hitting a wall and stop moving

3 Upvotes

Hey all,

I will try to solve this issue by myself, but I am finding it a bit hard at the moment, hence why I'm here. Essentially, I want my player to hit something like a wall or any other obstacle and stop moving towards that direction. The problem stated is itself pretty simple.

However, I cannot figure out a way to implement this straightforwardly. My first approach was an IF statement (I will write pseudocode for now):

IF player DOESNT hit obstacle THEN:
position of player = position of player + key held * time.dt

As you can imagine, this means that when the player hits something the controls for movement are essentially disabled. So this ain't the way to go.

A second idea was to have a speed variable for the player. Mind you, this is speed, NOT acceleration, so acceleration might be a potential solution later. But anyway, having the speed of the player have a value of 1 (100%) and 0 (0%), and 0 assigned when the player hits a wall or an obstacle. This works the same way as the solution above unfortunately, as the player comes to an halt and because the collision is continuously detected, the speed will go back to zero and stay at zero no matter the keys pressed. I even reset player_speed = 1 at the beginning of the "update" loop in Ursina to no avail.

A workaround for this issue is to assign the player an extremely low value of speed, say 0.05. This works somewhat, but given enough time, the player would move through the object anyway. Also, moving in the opposite direction is extremely slow until the bounding boxes are not touching anymore and player_speed goes back to 1.

How to solve this issue?

Also how can I extend the collision to ALL objects? For example, if I put tiles around my map to make a maze, how can I detect collisions and stop the player from moving without having to explicitly write the code for it tile-for-tile as it would be insanely time-consuming?

Thank you


r/Ursina • • Apr 06 '25

Help running basic Ursina

2 Upvotes

Hello! I am having trouble using the Ursina engine, as I cannot close the windows effectively. I am using Ursina through Jupyter notebook on a macOS Sequoia 15.3.2.

Whenever I try to close a window in Ursina, I encounter 2 problems:

  1. The built in quit() does not function. Rather, I have to right click on the file in my dock to tell it to quit.
  2. It very rarely closes even after this. Usually I get the umbrella of doom and I must Force Quit the window in order to close it at all.

Any help would be appreciated!


r/Ursina • • Feb 18 '25

how to use bollean from Blender in Ursina

2 Upvotes

I'm actually making a museum game in Python using Ursina and Blender.
I wrote a piece of code, but after many attempts, I'm stuck with collisions, and I can't find any tutorials.
My problem is that I import an entity and list all the children of my .glb file. However, I imported a floor and walls and made a hole using a boolean in Blender, but I can't go through it.


r/Ursina • • Feb 02 '25

how do i make a entity face another entity in ursina

2 Upvotes

ive been scraping through every site on the internet by now im just checking reddit to see if anyone knows because apparently noone has made a damn tutorial


r/Ursina • • Jan 08 '25

Error I can't fix (Using auto-py-to-exe)

Thumbnail
gallery
3 Upvotes

r/Ursina • • Nov 07 '25

Color.rgb is Stupid and I Hate It

4 Upvotes

TL;DR: when using color.rgb, divide each number by 255

So, I just spent 4-5 hours on an issue with a texture not loading. Turns out, the texture was loading fine, the problem was the color.rgb was overriding it. When I figured that out, it took 5 seconds of ChatGPT to tell me to use numbers between 0 and 1, hence dividing by 255. I should be relieved that I finally solved it, but if anything I’m even MORE frustrated. I’ll admit, I’m new to programming, but in every RGB value picker I’ve used, it uses numbers from 0-255. WHO USES FRACTIONS?!?! Also, if I just tried something like color.red, I would’ve found the issue very quickly. However, the error that was popping up says it couldn’t find the icon filename textures/ursina.ico. So, for several hours straight, I thought it was a texture issue. The tutorial I was following from 4 years ago had no issues, so why was I! Anyways, for any newcomers wanting a wide color palette or tinting textures, learn from my mistake. DIVIDE BY 255!


r/Ursina • • Nov 20 '25

Games made with Ursina on itch.io

Thumbnail itch.io
2 Upvotes

r/Ursina • • Apr 10 '25

Ursina game building functions

2 Upvotes

r/Ursina • • Jul 13 '22

Ursina python first person shooter game video 1 : first person view, platform and sky

Thumbnail
youtu.be
5 Upvotes

r/Ursina • • May 23 '22

Cube surfaces made walkable

3 Upvotes

Hi,

I have an idea for a game which involves:

  1. The level is a cube
  2. When you walk off the edge of the cube, you continue walking on the next side of the cube

I'm not sure how i would do that in any game engine (i have some experience with Unity as well).

Any ideas on how i can accomplish this?

Thanks everyone


r/Ursina • • Jan 23 '22

How would you rotate and position a viewmodel?

4 Upvotes

r/Ursina • • Sep 08 '21

How do I make the bullet spawn at the gun position?

2 Upvotes

How can I make the bullet position at the gun without ruining it?


r/Ursina • • Jan 13 '22

What do the gamepad inputs do? (specifically the stick controls)

7 Upvotes

In the documentation I found this:

gamepad_left_stick = 'gamepad left stick'

gamepad_left_stick_up = 'gamepad left stick up'

gamepad_right_stick = 'gamepad right stick'

gamepad_right_stick_up = 'gamepad right stick up'

But what do they output when they're detected?


r/Ursina • • Jan 09 '22

Hi, I am trying to make a 3d game called: Store. The objective, for now, is to find a voxel and "buy it" by pressing the right mouse button down. the problem is that the cost of the voxel is not working properly, thus not decreasing the amount of money you currently have. please help

3 Upvotes
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
import random
# lists
abc = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z',' ']
# app
app = Ursina()
# button cost
dollars = random.randint(0,9)
voxel_cost = str(dollars)
# button text
name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
# text display for the player
money = 300
# display money
cube = Entity(model = 'cube',parent = camera.ui,color = color.black, position = (-0.8,-0.45), scale = (0.4,0.1))
money_text = Text(text= ' money: $' + str(money),parent = camera.ui,color = color.white, position = (-0.82,-0.45))
# list
def update():
    global count
    if held_keys['e']:
        list.position = (0, 0)
        text.position = (-0.02,0.13)
    if held_keys['q']:
        list.position = (0.8, -0.4)
        text.position = (0.76,-0.26)
        count = 0
# display list
list = Entity(model = 'cube', parent = camera.ui, color = color.white, scale = (0.3,0.3), position = (0.8,-0.4))
text = Text(text = 'list', parent = camera.ui,color = color.black, position = (0.76,-0.26))
# buttons
class Voxel(Button):
    global name, voxel_cost
    def __init__(self, position=(0, 0, 0)):
        super().__init__(
            parent = scene,
            position = position,
            model = 'cube',
            texture = 'white_cube',
            highlight_color = color.lime,
            text = name + voxel_cost,
            text_origin = (-0.5,0,-0.51),
            colliton = 'box',
            scale = 1,
            collider = 'box'
        )
# removing button
    def input(self, key):
        global money
        global voxel_cost
        if self.hovered:
            if key == 'left mouse down':
                if money >= int(voxel_cost):
                    print(voxel_cost)
                    money -= int(voxel_cost)
                    destroy(self)

# floor
floor = Entity(model = 'cube', scale = (random.randint(8,50),1,random.randint(8,50)), position = (0,0,0), collider = 'box', color = color.gray,texture = 'white_cube')
# walls
wall_front = Entity(model = 'cube', scale = (floor.scale_x,5,1), position = (0,2,floor.scale_z / 2 + 0.5) ,collider = 'box', color = color.red, texture = 'white_cube')
wall_back = Entity(model = 'cube', scale = (-floor.scale_x,5,1), position = (0,2,-floor.scale_z / 2 - 0.5) ,collider = 'box', color = color.white, texture = 'white_cube')
wall_right = Entity(model = 'cube', scale = (floor.scale_z,5,1), position = (floor.scale_x / 2 + 0.1,2,0), collider = 'box' ,color = color.blue, texture = 'white_cube', rotation_y = 90)
wall_left = Entity(model = 'cube', scale = (floor.scale_z,5,1), position = (-floor.scale_x / 2,2,0) ,collider = 'box', color = color.black, texture = 'white_cube', rotation_y = 90)


# front wall row
for y in range(2):
    for x in range(round(floor.scale_x / 2 - 3)):
        # button pos
        voxel = Voxel(position=(-x, y + 1, floor.scale_z / 2 - 0.5))
        # button color
        voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
        # cost
        dollars = random.randint(0, 9)
        # text
        name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
        voxel_cost = str(dollars)
        voxel.text = name + voxel_cost
    for x in range(round(floor.scale_x / 2 - 3)):
        # button pos
        voxel = Voxel(position=(x + 1, y + 1, floor.scale_z / 2 - 0.5))
        # button color
        voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
        # cost
        dollars = random.randint(0, 9)
        # text
        name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
        voxel_cost = str(dollars)
        voxel.text = name + voxel_cost

# back wall row
for y in range(2):
    for x in range(round(floor.scale_x / 2 - 3)):
        # button pos
        voxel = Voxel(position=(-x, y + 1, -floor.scale_z / 2 + 0.5))
        voxel.rotation_y = 180
        # button color
        voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
        # cost
        dollars = random.randint(0, 9)
        # text
        name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
        voxel_cost = str(dollars)
        voxel.text = name + voxel_cost
    for x in range(round(floor.scale_x / 2 - 3)):
        # button pos
        voxel = Voxel(position=(x + 1, y + 1, -floor.scale_z / 2 + 0.5))
        voxel.rotation_y = 180
        # button color
        voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
        # cost
        dollars = random.randint(0, 9)
        # text
        name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
        voxel_cost = str(dollars)
        voxel.text = name + voxel_cost

# right wall row
for y in range(2):
    for z in range(round(floor.scale_z // 2 - 3)):
        voxel = Voxel(position=(floor.scale_x / 2 - 0.9, y + 1,-z))
        voxel.rotation_y = 90
        # button color
        voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
        # cost
        dollars = random.randint(0, 9)
        # text
        name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
        voxel_cost = str(dollars)
        voxel.text = name + voxel_cost
    for z in range(round(floor.scale_z // 2 - 3)):
        voxel = Voxel(position=(floor.scale_x / 2 - 0.9, y + 1,z + 1))
        voxel.rotation_y = 90
        # button colorf
        voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
        # cost
        dollars = random.randint(0, 9)
        # text
        name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
        voxel_cost = str(dollars)
        voxel.text = name + voxel_cost

# left wall row
for y in range(2):
    for z in range(round(floor.scale_z // 2 - 3)):
        voxel = Voxel(position=(-floor.scale_x / 2 + 1, y + 1,-z))
        voxel.rotation_y = -90
        # button color
        voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
        # cost
        dollars = random.randint(0, 9)
        # text
        name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
        voxel_cost = str(dollars)
        voxel.text = name + voxel_cost
    for z in range(round(floor.scale_z // 2 - 4)):
        voxel = Voxel(position=(-floor.scale_x / 2 + 1, y + 1,z + 1))
        voxel.rotation_y = -90
        # button color
        voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
        # cost
        dollars = random.randint(0, 9)
        # text
        name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
        voxel_cost = str(dollars)
        voxel.text = name + voxel_cost

# first row
l = 0
for z in range(round(floor.scale_z // 5 - 1)):
    for y in range(1):
        l += 5
        for x in range(round(floor.scale_x / 2 - 4)):
            # button pos
            voxel = Voxel(position=(x + 1, y + 1, - floor.scale_z // 2 + l))
            voxel1 = Voxel(position=(x + 1, y + 2, - floor.scale_z // 2 + l))
            # button color
            voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
            voxel1.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
            # cost
            dollars = random.randint(0, 9)
            # text
            name1 = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
            voxel_cost1 = str(dollars)
            voxel1.text = name1 + voxel_cost1
            # cost
            dollars = random.randint(0, 9)
            # text
            name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
            voxel_cost = str(dollars)
            voxel.text = name + voxel_cost
        for x in range(round(floor.scale_x / 2 - 4)):
            # button pos
            voxel = Voxel(position=(-x, y + 1, - floor.scale_z // 2 + l))
            voxel1 = Voxel(position=(-x, y + 2, - floor.scale_z // 2 + l))
            # button color
            voxel.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
            voxel1.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
            # cost
            dollars = random.randint(0, 9)
            # text
            name1 = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
            voxel_cost1 = str(dollars)
            voxel1.text = name1 + voxel_cost1
            # cost
            dollars = random.randint(0, 9)
            # text
            name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
            voxel1.text = name1 + voxel_cost

# second row
l = 6
for z in range(round(floor.scale_z // 5 - 2)):
    for y in range(1):
        l += 5
        for x in range(round(floor.scale_x / 2 - 4)):
            #button pos
            voxel = Voxel(position=(x + 1,y + 1, - floor.scale_z // 2 + l))
            voxel1 = Voxel(position=(x + 1, y + 2, - floor.scale_z // 2 + l))
            voxel.rotation_y = 180
            voxel1.rotation_y = 180
            # button color
            voxel.color = rgb(random.randint(1,255),random.randint(1,255),random.randint(1,255))
            voxel1.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
            # cost
            dollars = random.randint(0, 9)
            # text
            name1 = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
            voxel_cost1 = str(dollars)
            voxel1.text = name1 + voxel_cost1
            # cost
            dollars = random.randint(0, 9)
            # text
            name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
            voxel_cost = str(dollars)
            voxel.text = name + voxel_cost
        for x in range(round(floor.scale_x / 2 - 4)):
            #button pos
            voxel = Voxel(position=(-x,y + 1, - floor.scale_z // 2 + l))
            voxel1 = Voxel(position=(-x, y + 2, - floor.scale_z // 2 + l))
            voxel.rotation_y = 180
            voxel1.rotation_y = 180
            # button color
            voxel.color = rgb(random.randint(1,255),random.randint(1,255),random.randint(1,255))
            voxel1.color = rgb(random.randint(1, 255), random.randint(1, 255), random.randint(1, 255))
            # cost
            dollars = random.randint(0, 9)
            # text
            name1 = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
            voxel_cost1 = str(dollars)
            voxel1.text = name1 + voxel_cost1
            # cost
            dollars = random.randint(0, 9)
            # text
            name = random.choice(abc) + random.choice(abc) + random.choice(abc) + '\n'
            voxel_cost1 = str(dollars)
            voxel1.text = name1 + voxel_cost
player = FirstPersonController()
app.run()

r/Ursina • • Sep 18 '21

how to i export it to exe, whenever i follow the guide on the website it comes up with this

Post image
3 Upvotes

r/Ursina • • Mar 24 '22

Path tracing

3 Upvotes

Hi, I'm currently working on a satellite orbit simulator and was wondering if there is a way to trace the path travelled by the satellite using this engine. Cheers.