mirror of
https://port.numenaute.org/aleajactaest/khanat-client.git
synced 2024-11-09 16:59:03 +00:00
66 lines
2.1 KiB
GDScript3
66 lines
2.1 KiB
GDScript3
|
extends Spatial
|
||
|
|
||
|
onready var camera_tps = $character/spring_arm/camera_tps
|
||
|
onready var camera_fps = $character/spring_arm/camera_fps
|
||
|
|
||
|
var mouse_delta = Vector2.ZERO
|
||
|
var zoom_level = 0
|
||
|
var camera_position = Vector3( 0.0, 2.0, -2.0 )
|
||
|
|
||
|
var proximity_objects = []
|
||
|
var focused_object = null
|
||
|
var focus_index = 0
|
||
|
|
||
|
static func get_input_direction() -> Vector3:
|
||
|
return Vector3(
|
||
|
Input.get_action_strength("move_strafe_right") - Input.get_action_strength("move_strafe_left"),
|
||
|
0,
|
||
|
Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward")
|
||
|
)
|
||
|
|
||
|
func _input( event ):
|
||
|
# Run.
|
||
|
if event.is_action_pressed( "move_toggle_run" ):
|
||
|
$character.is_running = not $character.is_running
|
||
|
# Camera.
|
||
|
if event.is_action( "camera_zoom_in" ):
|
||
|
self.zoom_level += 1
|
||
|
elif event.is_action( "camera_zoom_out" ):
|
||
|
self.zoom_level -= 1
|
||
|
if event.is_action_pressed( "camera_reset_view" ):
|
||
|
$character/spring_arm.rotation = Vector3.ZERO
|
||
|
self.zoom_level = 0
|
||
|
if event.is_action_pressed( "camera_switch" ):
|
||
|
if self.camera_tps.current:
|
||
|
self.camera_fps.make_current()
|
||
|
$character/spring_arm.rotation = Vector3.ZERO
|
||
|
# self.hide()
|
||
|
else:
|
||
|
self.camera_tps.make_current()
|
||
|
# self.show()
|
||
|
if event is InputEventMouseMotion:
|
||
|
self.mouse_delta = event.relative
|
||
|
# Jump.
|
||
|
if event.is_action_pressed( "move_jump" ) and not $character.is_falling:
|
||
|
$character.is_jump_started = true
|
||
|
if event.is_action_pressed( "interact" ):
|
||
|
# self.interact()
|
||
|
pass
|
||
|
if event.is_action_pressed( "focus_next" ):
|
||
|
# self.focus_next()
|
||
|
pass
|
||
|
|
||
|
func _process( delta ):
|
||
|
$character.direction = self.get_input_direction()
|
||
|
# Rotation.
|
||
|
if not Input.is_key_pressed( KEY_SHIFT ) and not $character.is_jump_started:
|
||
|
$character.orientation = (Input.get_action_strength("move_turn_left") - Input.get_action_strength("move_turn_right"))
|
||
|
else:
|
||
|
$character.orientation = 0.0
|
||
|
# Camera.
|
||
|
if not self.mouse_delta == Vector2.ZERO and self.camera_tps.current:
|
||
|
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||
|
$character/spring_arm.rotate_y( -self.mouse_delta.x * 0.01 )
|
||
|
self.camera_tps.rotate_x( self.mouse_delta.y * 0.01 )
|
||
|
|