extends Spatial var player_speed = 1.0 var player_rotation_speed = 0.1 var mouse_old_position = null var mouse_delta = Vector2( 0.0, 0.0 ) var camera_zoom_speed = 0.5 var camera_zoom = 0.0 var heightmap = null func _input( event ): var movment = Vector3( 0.0, 0.0, 0.0 ) var rotation = Vector3( 0.0, 0.0, 0.0 ) if event.is_action( "move_forward" ): movment.z += self.player_speed elif event.is_action( "move_backward" ): movment.z -= self.player_speed elif event.is_action( "move_left" ): movment.x += self.player_speed elif event.is_action( "move_right" ): movment.x -= self.player_speed if event.is_action( "turn_left" ): rotation.y += self.player_rotation_speed elif event.is_action( "turn_right" ): rotation.y -= self.player_rotation_speed $creatures/player.turn( rotation ) $creatures/player.move( movment ) if event.is_action( "zoom_in" ): self.camera_zoom -= self.camera_zoom_speed elif event.is_action( "zoom_out" ): self.camera_zoom += self.camera_zoom_speed if event.is_action_pressed( "free_look" ): self.mouse_old_position = event.position elif event.is_action_released( "free_look" ): self.mouse_old_position = null if event.is_action( "reset_camera" ): $creatures/player.reset_camera() if event is InputEventMouseMotion: if not mouse_old_position == null: self.mouse_delta = self.mouse_old_position - event.position self.mouse_old_position = event.position func _process( delta ): # $camera_base.translate( camera_translation ) # camera_translation = Vector3() # $camera_base.rotate( Vector3( 0.0, 1.0, 0.0 ), deg2rad( camera_rotation ) ) $creatures/player.rotate_camera_arm( Vector3( 0.0, 1.0, 0.0 ), deg2rad( self.mouse_delta.x ) ) $creatures/player.move_camera( Vector3( 0.0, 0.0, camera_zoom ) ) $creatures/player.rotate_camera( Vector3( 1.0, 0.0, 0.0 ), deg2rad(-self.mouse_delta.y ) ) # camera_rotation = 0.0 self.camera_zoom = 0.0 self.mouse_delta = Vector2( 0.0, 0.0 ) func load_player( filename ): $creatures/player.load_creature( filename ) func _on_debug_window_time_of_day_changed(value): $sky/viewport/sky.set_day_time_hours(( value )) func _on_debug_window_mist_level_changed(value): $mist_fx.get_surface_material( 0 ).set_shader_param( "mist_level", value ) func _on_debug_window_douleur_minus_pressed(): $game_ui.change_douleur( -1 ) func _on_debug_window_douleur_plus_pressed(): $game_ui.change_douleur( 1 ) func _on_debug_window_oubli_minus_pressed(): $game_ui.change_oubli( -1 ) func _on_debug_window_oubli_plus_pressed(): $game_ui.change_oubli( 1 )