update camera usage on fps

This commit is contained in:
AleaJactaEst 2022-02-06 23:41:32 +01:00
parent 4a05c059fd
commit 804a11d1ca

View file

@ -93,25 +93,41 @@ func switch_state(new_state):
#$carpet.hide()
camera_fps.rotate_x( -player_rotate_x )
player_rotate_x = 0
camera_fps = $camera_root/Camera3D_FPS_WALK
if get_viewport().get_camera_3d() == camera_fps:
camera_fps = $camera_root/Camera3D_FPS_WALK
camera_fps.make_current()
else:
camera_fps = $camera_root/Camera3D_FPS_WALK
StatePlayer.WALK:
print("switch camera WALK")
#$carpet.hide()
camera_fps.rotate_x( -player_rotate_x )
player_rotate_x = 0
camera_fps = $camera_root/Camera3D_FPS_WALK
if get_viewport().get_camera_3d() == camera_fps:
camera_fps = $camera_root/Camera3D_FPS_WALK
camera_fps.make_current()
else:
camera_fps = $camera_root/Camera3D_FPS_WALK
StatePlayer.FLY:
print("switch camera FLY")
#$carpet.show()
camera_fps.rotate_x( -player_rotate_x )
player_rotate_x = 0
camera_fps = $camera_root/Camera3D_FPS_FLY
if get_viewport().get_camera_3d() == camera_fps:
camera_fps = $camera_root/Camera3D_FPS_FLY
camera_fps.make_current()
else:
camera_fps = $camera_root/Camera3D_FPS_FLY
StatePlayer.SWIM:
print("switch camera SWIM")
#$carpet.hide()
camera_fps.rotate_x( -player_rotate_x )
player_rotate_x = 0
camera_fps = $camera_root/Camera3D_FPS_SWIM
if get_viewport().get_camera_3d() == camera_fps:
camera_fps = $camera_root/Camera3D_FPS_SWIM
camera_fps.make_current()
else:
camera_fps = $camera_root/Camera3D_FPS_SWIM
func search_animation( obj:Node , root:String = "/") -> bool:
@ -198,12 +214,8 @@ func _input(event):
elif Input.is_action_just_pressed("switch_state_player"):
match state_player:
StatePlayer.WALK:
print("FLY")
#state_player = StatePlayer.FLY
switch_state(StatePlayer.FLY)
StatePlayer.FLY:
print("SWIM")
#state_player = StatePlayer.WALK
switch_state(StatePlayer.WALK)
# If right mouse button is pressed and mouse moves, pan horizontally camera
@ -235,14 +247,14 @@ func _input(event):
$camera_root/horizontal_root/vertical_root.rotate_x( event.relative.y * 0.01 )
camera_rotate_x = new_camera_rotate_x
else:
player_rotate_y += event.relative.x *0.01
if player_rotate_y > PI:
player_rotate_y -= TAU
elif player_rotate_y <= -PI:
player_rotate_y += TAU
camera_rotate_y = player_rotate_y
rotate_y( -event.relative.x *0.01 )
player_rotate_y += event.relative.x *0.01
rotate_y( -event.relative.x *0.01 )
var new_camera_rotate_x = player_rotate_x + event.relative.y * 0.01
if new_camera_rotate_x <= PI_2 and new_camera_rotate_x >= - PI_2:
camera_fps.rotate_x( event.relative.y * 0.01 )