[英]Ursina FirstPersonController Change Collider Not Working
我正在使用Python
的Panda3D
包装器来运行一些第一人称游戏测试。 我希望名为FirstPersonController
的ursina
相机类型的对撞机将其对撞机扩展到精灵上。 我已经尝试过使用 BoxCollider()(但我并不真正知道如何使用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()
请帮忙,所有建议都有帮助!
要显示第三人称视角,您可以将全局相机向后移动:
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.