Пытаюсь сделать 3D игру на ursina
Вот код:
from ursina import *
from ursina.editor.level_editor import y
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
class Voxel(Button):
def __init__(self, position=(0,0,0)):
super().__init__(
parent = scene,
position = position,
model = 'cube',
origin_y = .5,
texture = 'white_cube',
color = color.color(0, 0, random.uniform(.9, 1.0)),
highlight_color = color.lime,
)
def input(self, key):
if self.hovered:
if key == 'left mouse down':
voxel = Voxel(position=self.position + mouse.normal)
if key == 'right mouse down':
destroy(self)
for z in range(8):
for x in range(8):
voxel = Voxel(position=(x, y,z))
player = FirstPersonController()
app.run()
Получаю ошибку:
Traceback (most recent call last):
File "/home/meliorator1333/PycharmProjects/3Dproekt/code/main.py", line 2, in <module>
from ursina.editor.level_editor import y
File "/home/meliorator1333/PycharmProjects/3Dproekt/venv/lib/python3.8/site-packages/ursina/editor/level_editor.py", line 1199, in <module>
level_editor = LevelEditor()
File "/home/meliorator1333/PycharmProjects/3Dproekt/venv/lib/python3.8/site-packages/ursina/editor/level_editor.py", line 122, in __init__
self.origin_mode_menu = ButtonGroup(['last', 'center', 'individual'], min_selection=1, position=window.top)
File "/home/meliorator1333/PycharmProjects/3Dproekt/venv/lib/python3.8/site-packages/ursina/prefabs/button_group.py", line 27, in __init__
self.select(self.buttons[i])
IndexError: list index out of range
Что в таком случае делать?
Ответы (1 шт):
Автор решения: Kriventsevivan Kriventsev
→ Ссылка
Смотри,
for z in range(8):
for x in range(8):
voxel = Voxel(position=(x, y,z))
У тебя нет переменной y, вместо нее напиши ноль.
Это можешь удалить:
from ursina.editor.level_editor import y