简体   繁体   中英

How can I make the player go forward? (Ursina Python)

class Player(Entity):
    def __init__(self):
        self.controller = Entity(
            model = 'cube',
            parent = camera
        )
        super().__init__(parent=self.controller)
        
    def update(self):
        if held_keys['a']:
            camera.rotation_y -= 50 * time.dt
            self.controller.rotation_y = camera.rotation_y
            if camera.rotation_y < -360: camera.rotation_y = 0
            
        if held_keys['d']:
            camera.rotation_y += 50 * time.dt
            self.controller.rotation_y = camera.rotation_y
            if camera.rotation_y > 360: camera.rotation_y = 0
entity = Entity(model='cube')

def update():
    entity.position += entity.forward

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM