#pip install panda3d
#python -m pip install panda3d
from ursina import *
from direct.actor.Actor import Actor
app = Ursina()
entity = Entity(
scale=0.5, # размер объекта
position=(0,3,0), # Позиция в пространстве
rotation=(0,-90,0) # Направление по градусу
)
cube = Entity(
model="cube",
color=color.brown,
scale=(30,3,30),
position=(0,-1,0)
)
actor = Actor(
'player.glb',
{
'walk': 'player.glb',
'idle': 'player.glb'
}
)
actor.loop('idle')
speed = 2
def update():
moving = False
if held_keys['w']:
entity.z += time.dt * speed
moving = True
entity.rotation_y = 90
if held_keys['s']:
entity.z -= time.dt * speed
moving = True
entity.rotation_y = -90
if held_keys['a']:
entity.x -= time.dt * speed
moving = True
entity.rotation_y = -180
if held_keys['d']:
entity.x += time.dt * speed
moving = True
entity.rotation_y = 180
if moving: # True / False ==
if actor.getCurrentAnim() != 'walk':
actor.loop('walk')
else:
actor.stop()
actor.reparent_to(entity)
actor.loop('walk') # запуск анимации
EditorCamera()
app.run()