Ok in my code i was trying to get the camera to follow my player and i was following a tutorial i found on stack overflow. But when I did it the player "fell" and rotates on its y axis how did this happen and also I tried to spawn the ground class but i dont think i did. And looked on all the docs for ursina and looking at how to videos, I still dont understand why. wht did i do wrong?
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
EditorCamera()
cam = FirstPersonController()
class Player(Entity):
def __init__(self, **kwargs):
super().__init__(model='cube', color=color.orange, collider='box', origin = (0, 0, -2), parent = cam)
self.health_bar = Entity(parent=self, model='quad', color=color.red, scale_y=.1, y=1.2)
self.max_health = 100
self.health = self.max_health
class Beings(Entity):
def __init__(self, **kwargs):
super().__init__(model='cube', color=color.gray, scale=2, collider='box', position=Vec3(1,0,2), origin_y=-.5)
self.health_bar = Entity(parent=self, model='quad', color=color.red, scale_y=.1, y=1.2)
self.max_health = 100
self.health = self.max_health
class Ground(Entity):
def __init__(self, **kwargs):
super().__init__(model='plane', color=color.gray, scale=2, collider='mesh', position=Vec3(1,0,2), origin_y=-.4)
self.health_bar = Entity(parent=self, model='quad', color=color.red, scale_y=.1, y=1.2)
self.max_health = 100
self.health = self.max_health
class Buildings(Entity):
def __init__(self, **kwargs):
super().__init__(model='cube', color=color.gray, scale=2, collider='box', position=Vec3(1,0,2), origin_y=-.5)
self.health_bar = Entity(parent=self, model='quad', color=color.red, scale_y=.1, y=1.2)
self.max_health = 100
self.health = self.max_health
class plants(Entity):
def __init__(self, **kwargs):
super().__init__(model='cube', color=color.gray, scale=2, collider='box', position=Vec3(1,0,2), origin_y=-.5)
self.health_bar = Entity(parent=self, model='quad', color=color.red, scale_y=.1, y=1.2)
self.max_health = 100
self.health = self.max_health
class Earth(Entity):
def __init__(self, **kwargs):
super().__init__(model='cube', color=color.gray, scale=2, collider='box', position=Vec3(1,0,2), origin_y=-.5)
self.health_bar = Entity(parent=self, model='quad', color=color.red, scale_y=.1, y=1.2)
self.max_health = 100
self.health = self.max_health
b = Beings()
p = Player()
def update():
Ground()
p.z += (held_keys['w'] - held_keys['s']) * time.dt * 6
p.x += (held_keys['d'] - held_keys['a']) * time.dt * 6
if p.intersects(b).hit:
b.color = color.lime
print('player is inside trigger box')
else:
b.color = color.gray
app.run()