简体   繁体   中英

how do i make a car in Ursina firstpersoncontroller rotate using the 'a' and 'd' keys, not the mouse

in Ursina i am trying to make a simple 3d car game with FirstPersonController, how do i make the player/car rotate using 'a' and 'd' keys, without using the mouse. turn like a car would when you turn a corner in real life the view moves with the turn

After line

def update():

Try to add following lines:

    if held_keys['d']:                          # If d is pressed
        car.rotation_y += time.dt * 5                # turn car right
        camera.rotation_y += time.dt * 5             # turn camera right
    if held_keys['a']:                          # If a is pressed
        camera.rotation_y -= time.dt * 5             # turn camera left
        car.rotation_y -= time.dt * 5                # turn car left

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