I'm making game with the Ursina engine and I make animations and collision stop working. I tried adding colliders to player and animation states, but both don't work.
from ursina import *
from ursina import curve, Entity
app = Ursina()
def update():
# movement
if held_keys['w'] or held_keys['a'] or held_keys['s'] or held_keys['d']:
player.y += held_keys['w'] * 4 * time.dt
player.y -= held_keys['s'] * 4 * time.dt
player.x -= held_keys['a'] * 4 * time.dt
player.x += held_keys['d'] * 4 * time.dt
# animation controller
if held_keys['w'] and held_keys['d']:
animator.state = 'u'
elif held_keys['w'] and held_keys['a']:
animator.state = 'u'
elif held_keys['d'] and held_keys['s']:
animator.state = 'down'
elif held_keys['a'] and held_keys['s']:
animator.state = 'down'
elif held_keys['s']:
animator.state = 'down'
elif held_keys['w']:
animator.state = 'u'
elif held_keys['d']:
animator.state = 'r'
elif held_keys['a']:
animator.state = 'l'
else:
animator.state = 'idle'
def input(key):
if key == "left mouse down":
x, y, z = mouse.position
real_pos = player.position + (camera.fov * x, camera.fov * y, 0)
direction = [real_pos[0] - player.x, real_pos[1] - player.y, 0]
dot = Entity(model='sphere', color=color.black, scale=1, position=player.position, collider='sphere',
tag='bullet')
dot.animate_position(player.position + [3 * p for p in direction], duration=1, curve=curve.linear)
invoke(destroy, dot, delay=0.5)
# animations
player = Entity()
animator = Animator(animations={
"idle": Entity(parent=player, model="quad", texture="assets/idle", scale=(2, 2, 0)),
"down": Animation("assets/down", parent=player, autoplay=False, scale=(2, 2, 0)),
"dl": Animation("assets/dl", parent=player, autoplay=False, scale=(2, 2, 0)),
"l": Animation("assets/l", parent=player, autoplay=False, scale=(2, 2, 0)),
"r": Animation("assets/r", parent=player, autoplay=False, scale=(2, 2, 0)),
"u": Animation("assets/u", parent=player, autoplay=False, scale=(2, 2, 0))
})
map = Entity(model="quad", color=color.red, position=(1, 1, 0))
map1 = Entity(model="diamond", color=color.red, position=(1, 1.5, 0))
# kamera
camera.orthographic = True
camera.fov = 20
follow = SmoothFollow(target=player, speed=8, offset=[0, 0, -4])
camera.add_script(follow)
app.run()