首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ursina FirstPersonController更改碰撞器不工作

Ursina FirstPersonController更改碰撞器不工作
EN

Stack Overflow用户
提问于 2021-05-07 00:39:58
回答 1查看 176关注 0票数 0

我的问题

我正在使用PythonPanda3D包装器来运行一些第一人称游戏测试。我希望名为FirstPersonControllerursina相机类型的对撞机在精灵上扩展其对撞机。我试过使用BoxCollider() (不知道怎么做,因为Ursina上没有很多教程),但我真的不知道怎么做。有谁可以帮我?

我的代码

代码语言:javascript
复制
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()

请帮助,所有的建议都是有帮助的!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-23 20:58:10

要显示第三人称透视,可以将全局摄影机向后移动:

代码语言:javascript
复制
def to_first_person():
    camera.position = (0, 0, 0)

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

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

代码语言:javascript
复制
def input(key):
    if key == '1':
        to_first_person()
    if key == '3':
        to_third_person()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67422483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档