SteveStage

Camera Rotation every 45 degrees

Jun 1st, 2021 (edited)
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. func _process(delta):
  2.     if Input.is_action_pressed("ui_up"):
  3.         if Input.is_action_pressed("ui_right"):
  4.             rot_y = rotation.y - PI/4
  5.         elif Input.is_action_pressed("ui_left"):
  6.             rot_y = rotation.y + PI/4
  7.         else:
  8.             rot_y = rotation.y
  9.     elif Input.is_action_pressed("ui_down"):
  10.         if Input.is_action_pressed("ui_right"):
  11.             rot_y = (rotation.y - PI/4) - PI/2
  12.         elif Input.is_action_pressed("ui_left"):
  13.             rot_y = (rotation.y + PI/4) + PI/2
  14.         else:
  15.             rot_y = rotation.y - PI
  16.     elif Input.is_action_pressed("ui_right"):
  17.         if Input.is_action_pressed("ui_up"):
  18.             rot_y = rotation.y - PI/4
  19.         elif Input.is_action_pressed("ui_down"):
  20.             rot_y = (rotation.y - PI/4) - PI/2
  21.         else:
  22.             rot_y = rotation.y - PI/2
  23.     elif Input.is_action_pressed("ui_left"):
  24.         if Input.is_action_pressed("ui_up"):
  25.             rot_y = rotation.y + PI/4
  26.         elif Input.is_action_pressed("ui_down"):
  27.             rot_y = (rotation.y + PI/4) + PI/2
  28.         else:
  29.             rot_y = rotation.y + PI/2
Add Comment
Please, Sign In to add comment