Upload files to 'entities/player'

This commit is contained in:
latenightz 2021-04-26 20:44:17 +00:00
parent 1abc4ef824
commit 1a0f2a100b
2 changed files with 45 additions and 2 deletions

View File

@ -26,3 +26,37 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
keep_aspect = 0
fov = 80.0
far = 250.0
[node name="Node2D" type="Node2D" parent="."]
[node name="HSlider" type="HSlider" parent="Node2D"]
margin_left = 108.021
margin_top = 10.4773
margin_right = 460.021
margin_bottom = 43.4773
min_value = 15.0
max_value = 150.0
value = 97.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Node2D"]
margin_left = 70.7272
margin_top = 20.9431
margin_right = 125.727
margin_bottom = 43.9431
text = "FOV:"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="fps_num" type="Label" parent="Node2D"]
margin_left = 466.032
margin_top = 20.0198
margin_right = 535.032
margin_bottom = 59.0198
text = "placehold"
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -6,7 +6,7 @@ extends KinematicBody
export(float) var mouse_sensitivity = 12.0
export(NodePath) var head_path
export(NodePath) var cam_path
export(float) var FOV = 80.0
export(float) var FOV = 120.0
var mouse_axis := Vector2()
onready var head: Spatial = get_node(head_path)
onready var cam: Camera = get_node(cam_path)
@ -42,6 +42,8 @@ func _ready() -> void:
func _process(_delta: float) -> void:
move_axis.x = Input.get_action_strength("move_forward") - Input.get_action_strength("move_backward")
move_axis.y = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
# Called every physics tick. 'delta' is constant
@ -81,6 +83,7 @@ func walk(delta: float) -> void:
if Input.is_action_just_pressed("move_jump"):
_snap = Vector3.ZERO
velocity.y = jump_height
print("[DEBUG] Jumped")
# Apply Gravity
velocity.y -= gravity * delta
@ -91,9 +94,15 @@ func walk(delta: float) -> void:
_speed = sprint_speed
cam.set_fov(lerp(cam.fov, FOV * 1.05, delta * 8))
sprinting = true
# print("[DEBUG] Sprint is on") # Generally, this causes debug console spam, so you may wanna turn it off
var fovslide = $Node2D/HSlider.value
$Head/Camera.fov = fovslide
$Node2D/fps_num.text = str(fovslide)
else:
var fovslide = $Node2D/HSlider.value
$Node2D/fps_num.text = str(fovslide)
_speed = walk_speed
cam.set_fov(lerp(cam.fov, FOV, delta * 8))
cam.set_fov(lerp(cam.fov, fovslide, delta * 8))
sprinting = false
# Acceleration and Deacceleration