initial commit
This commit is contained in:
commit
cffda6e18e
58 changed files with 10952 additions and 0 deletions
47
psx_camera/fly_camera.gd
Normal file
47
psx_camera/fly_camera.gd
Normal file
|
@ -0,0 +1,47 @@
|
|||
extends Camera3D
|
||||
|
||||
@export_range(0, 10, 0.01) var sensitivity : float = 3
|
||||
@export_range(0, 1000, 0.1) var default_velocity : float = 5
|
||||
@export_range(0, 10, 0.01) var speed_scale : float = 1.17
|
||||
@export_range(1, 100, 0.1) var boost_speed_multiplier : float = 3.0
|
||||
@export var max_speed : float = 1000
|
||||
@export var min_speed : float = 0.2
|
||||
|
||||
@onready var _velocity = default_velocity
|
||||
|
||||
func _input(event):
|
||||
if not current:
|
||||
return
|
||||
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
if event is InputEventMouseMotion:
|
||||
rotation.y -= event.relative.x / 1000 * sensitivity
|
||||
rotation.x -= event.relative.y / 1000 * sensitivity
|
||||
rotation.x = clamp(rotation.x, PI/-2, PI/2)
|
||||
|
||||
if event is InputEventMouseButton:
|
||||
match event.button_index:
|
||||
MOUSE_BUTTON_RIGHT:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED if event.pressed else Input.MOUSE_MODE_VISIBLE)
|
||||
MOUSE_BUTTON_WHEEL_UP: # increase fly velocity
|
||||
_velocity = clamp(_velocity * speed_scale, min_speed, max_speed)
|
||||
MOUSE_BUTTON_WHEEL_DOWN: # decrease fly velocity
|
||||
_velocity = clamp(_velocity / speed_scale, min_speed, max_speed)
|
||||
if event is InputEventKey:
|
||||
if event.pressed and event.keycode == KEY_ESCAPE:
|
||||
get_tree().quit()
|
||||
|
||||
func _process(delta):
|
||||
if not current:
|
||||
return
|
||||
|
||||
var direction = Vector3(
|
||||
float(Input.is_physical_key_pressed(KEY_D)) - float(Input.is_physical_key_pressed(KEY_A)),
|
||||
float(Input.is_physical_key_pressed(KEY_E)) - float(Input.is_physical_key_pressed(KEY_Q)),
|
||||
float(Input.is_physical_key_pressed(KEY_S)) - float(Input.is_physical_key_pressed(KEY_W))
|
||||
).normalized()
|
||||
|
||||
if Input.is_physical_key_pressed(KEY_SHIFT): # boost
|
||||
translate(direction * _velocity * delta * boost_speed_multiplier)
|
||||
else:
|
||||
translate(direction * _velocity * delta)
|
Loading…
Add table
Add a link
Reference in a new issue