Ursina FirstPersonController 更改碰撞器不工作 我的代码

问题描述

我的问题

我正在使用 Panda3DPython 包装器来运行一些第一人称游戏测试。我希望名为 ursinaFirstPersonController 相机类型的碰撞器将其碰撞器扩展到精灵上。我已经尝试过使用 BoxCollider() 使用 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() (但我真的不知道如何去做,因为关于 Ursina 的教程并不多)但我真的不知道如何去做。有人可以帮我吗?

我的代码

{{1}}

请帮忙,所有建议都有帮助!

解决方法

要显示第三人称视角,您可以将全局相机向后移动:

def to_first_person():
    camera.position = (0,0)

def to_third_person():
    camera.position = (0,-3)

您可以在加载游戏时执行此操作,也可以通过键盘输入来回切换:

def input(key):
    if key == '1':
        to_first_person()
    if key == '3':
        to_third_person()