我的问题
我正在使用Python的Panda3D包装器来运行一些第一人称游戏测试。我希望名为FirstPersonController的ursina相机类型的对撞机在精灵上扩展其对撞机。我试过使用BoxCollider() (不知道怎么做,因为Ursina上没有很多教程),但我真的不知道怎么做。有谁可以帮我?
我的代码
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
class Player(Entity):
def __init__(self, parent):
super().__init__( # super() is used to access things from the inheriting class (in this case the Entity class)
model = 'cube',
color = color.red,
parent = parent
)
class Floor(Entity):
def __init__(self):
super().__init__(
model = 'cube',
scale = (40, 3, 40),
color = color.rgb(23, 45, 105),
position = (0, -20, 0),
collider = 'box'
)
app = Ursina()
window.fps_counter.enabled = False
window.fullscreen = True
cam = FirstPersonController()
player = Player(cam)
floor = Floor()
def update():
if held_keys['escape']:
application.quit()
Sky()
app.run()请帮助,所有的建议都是有帮助的!
发布于 2021-05-23 20:58:10
要显示第三人称透视,可以将全局摄影机向后移动:
def to_first_person():
camera.position = (0, 0, 0)
def to_third_person():
camera.position = (0, 0, -3)您可以在加载游戏时执行此操作一次,或者通过键盘输入来回切换:
def input(key):
if key == '1':
to_first_person()
if key == '3':
to_third_person()https://stackoverflow.com/questions/67422483
复制相似问题