Search code examples
pythonnameerrorursina

How to fix "name 'render' is not defined" in Ursina Engine?


So I've just started with "Ursina" Engine, I'm still very new to it. I'm trying to make a Minecraft game on Youtube tutorial with this Engine. And for some reason, the program keeps giving me the error name "Name 'render' is not defined". And I don't understand what that's saying. I tried to fix my code and skimmed over the code but couldn't find the answer.

This is all my code:

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

Sky(texture = 'sky.jpg')

class Voxel(Button):
    def __init__(self, position = (0,0,0)):
        super().__init__(
            model = 'cube',
            texture = 'white_cube',
            position = position,
            color = color.white,
            parent = scene,
            origin_y = 0.5,
            highlight_color = color.lime,
        )
    
app = Ursina()
player = FirstPersonController()
for x in range(12):
    for y in range(12):
        voxel = Voxel(position = (y,0,x))


app.run() 

This is the Traceback of the code:

PS C:\Users\lhnguyen1029> & "C:/Program Files (x86)/Python39- 
32/python.exe" "c:/Users/lhnguyen1029/OneDrive - Mesa Public 
Schools/Documents/CTE- Computer Science Principles/Ursina 
practice/ursina_practice(2).py"
package_folder: 
C:\Users\lhnguyen1029\AppData\Roaming\Python\Python39\site- 
packages\ursina
asset_folder: c:\Users\lhnguyen1029\OneDrive - Mesa Public 
Schools\Documents\CTE- Computer Science Principles\Ursina practice
screen resolution: (1366, 768)
Traceback (most recent call last):
 File "c:\Users\lhnguyen1029\OneDrive - Mesa Public 
Schools\Documents\CTE- Computer Science Principles\Ursina 
practice\ursina_practice(2).py", line 7, in <module>
Sky(texture = 'sky.jpg')
File "C:\Users\lhnguyen1029\AppData\Roaming\Python\Python39\site- 
packages\ursina\prefabs\sky.py", line 8, in __init__
parent = render,
NameError: name 'render' is not defined
PS C:\Users\lhnguyen1029> 

Solution

  • Instantiate Ursina() before instantiating entities.