I am using the Panda3D
wrapper for Python
to run some 1st person game tests. I would like the collider of the ursina
camera type called the FirstPersonController
to extend its collider over the sprite. I have tried (without really knowing how as there aren't many tutorials on Ursina) using a BoxCollider()
but I didn't really get how to do it. Can anyone help me?
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()
Please help, all suggestions are helpful!
To show a 3rd person perspective, you can move the global camera back:
def to_first_person():
camera.position = (0, 0, 0)
def to_third_person():
camera.position = (0, 0, -3)
You could either do this once when loading the game or switch back and forth via keyboard inputs:
def input(key):
if key == '1':
to_first_person()
if key == '3':
to_third_person()