簡體   English   中英

Ursina FirstPersonController 更改對撞機不工作

[英]Ursina FirstPersonController Change Collider Not Working

我的問題

我正在使用PythonPanda3D包裝器來運行一些第一人稱游戲測試。 我希望名為FirstPersonControllerursina相機類型的對撞機將其對撞機擴展到精靈上。 我已經嘗試過使用 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM