我对使用 Python 进行编程非常陌生,并且开始学习如何使用 Ursina 游戏引擎......
目前我正在通过 IDLE 运行 Python 3.9.4。我查找了一个使用 Ursina 进行不同活动的 YouTube 播放列表。但是,我在其中一个视频中遇到了障碍。即使我完全按照视频中显示的方式复制了代码,我仍然收到断言错误。
这是我收到的完整错误:
= RESTART: C:/Users/Charbel/Desktop/Ursina Tutorials/smooth follow - flying dragon.py
package_folder: C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\ursina
asset_folder: C:\Users\Charbel\Desktop\Ursina Tutorials
blender_paths:
{'2.7': WindowsPath('C:/Program Files/Blender Foundation/Blender/blender.exe'),
'2.8': WindowsPath('C:/Program Files/Blender Foundation/Blender 2.83/blender.exe'),
'default': WindowsPath('C:/Program Files/Blender Foundation/Blender 2.83/blender.exe')}
screen resolution: (1366, 768)
size; LVector2f(1092, 614)
render mode: default
development mode: True
application successfully started
Traceback (most recent call last):
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\showbase\ShowBase.py", line 2153, in __igLoop
self.graphicsEngine.renderFrame()
AssertionError: !mat.is_nan() at line 322 of c:\buildslave\sdk-windows-amd64\build\panda\src\pgraph\transformState.cxx
Traceback (most recent call last):
File "C:/Users/Charbel/Desktop/Ursina Tutorials/smooth follow - flying dragon.py", line 22, in <module>
app.run()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\ursina\main.py", line 238, in run
super().run()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\showbase\ShowBase.py", line 3325, in run
self.taskMgr.run()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\task\Task.py", line 546, in run
self.step()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\task\Task.py", line 500, in step
self.mgr.poll()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\showbase\ShowBase.py", line 2153, in __igLoop
self.graphicsEngine.renderFrame()
AssertionError: !mat.is_nan() at line 322 of c:\buildslave\sdk-windows-amd64\build\panda\src\pgraph\transformState.cxx
这是我的整个代码的副本:
from ursina import *
def update():
global dy
player.y += dy
if abs(player.y)>= 3:
dy = -dy
app = Ursina()
player = Entity(model='quad', scale=1, x = -4.5, texture = 'dragon_head.png')
e = [None]*50
e[0] = Entity(model='circle', scale = .2, color = color.green)
e[0].add_script(SmoothFollow(target = player, offset=(.3, 0, 0)))
dy =.08
for i in range(1,50):
e[i] = Entity(model='circle', scale = .2, color = color.green)
e[i].add_script(SmoothFollow(target = e[i-1], offset=(.2, 0, 0)))
app.run()
看来该错误与我调查的 e[i-1] 有关。有没有其他人遇到过类似的问题或知道 Ursina 语言中是否存在导致此问题的错误?
提前致谢
夏贝尔