tweaks to controller and savegames are stored by level

This commit is contained in:
Derek
2024-12-09 22:49:44 -06:00
parent 7ed9d2a774
commit 0ec82d84aa
10 changed files with 73 additions and 25 deletions

View File

@@ -23,7 +23,9 @@ const ADS_POS = Vector3(0,-.05,-.45)
#JOYSTICK SETTINGS
const JOYSTICK_SENSITIVITY = .06
var adj_sensitivity = JOYSTICK_SENSITIVITY
const JOYSTICK_DEADZONE = 0.05
const R_JOYSTICK_DEADZONE = 0.05
const L_JOYSTICK_DEADZONE = .2
const L_JOYSTICK_SENSITIVITY = .1
var speed
var double_jump = true
@@ -208,9 +210,18 @@ func _physics_process(delta):
velocity.y += JUMP_VELOCITY
double_jump = false
# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
var direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
## HANDLE MOVEMENT DIRECTION
var input_dir
var direction
#GetKB Input
input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
#Get Joy Input
input_dir += joypad_walk()
if abs(Input.get_joy_axis(0,JOY_AXIS_LEFT_X)) > L_JOYSTICK_SENSITIVITY or abs(Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)) > L_JOYSTICK_SENSITIVITY:
direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y))
else:
direction = (self.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# Handle Sprint
if Input.is_action_just_pressed("sprint") and !is_on_floor():
if air_dash > 0:
@@ -287,6 +298,7 @@ func _physics_process(delta):
var recoil_amount = Vector3(-.3,0,0)
land_sound.volume_db = land_volume
land_sound.play()
Input.start_joy_vibration(0,.1,.1,.1)
recoil.add_recoil(recoil_amount,10,10)
moving_fast_top_speed = 0.0
moving_fast = false
@@ -414,15 +426,28 @@ func _physics_process(delta):
weapon_sway(delta)
weapon_bob(velocity.length(), delta)
func joypad_walk():
# Joypad right stick look control
var dir_out = Vector2(0,0)
var xAxis = Input.get_joy_axis(0,JOY_AXIS_LEFT_X)
var yAxis = Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
if abs(xAxis) > L_JOYSTICK_DEADZONE:
dir_out.x = xAxis
if abs(yAxis) > L_JOYSTICK_DEADZONE:
dir_out.y = yAxis
return dir_out
func joypad_look(delta):
# Joypad right stick look control
var xAxis = Input.get_joy_axis(0,JOY_AXIS_RIGHT_X)
var yAxis = Input.get_joy_axis(0,JOY_AXIS_RIGHT_Y)
var aim_assist
if abs(xAxis) > JOYSTICK_DEADZONE:
if abs(xAxis) > R_JOYSTICK_DEADZONE:
self.rotate_y(-xAxis * JOYSTICK_SENSITIVITY * 1)
if abs(yAxis) > JOYSTICK_DEADZONE:
if abs(yAxis) > R_JOYSTICK_DEADZONE:
head.rotate_x(-yAxis * JOYSTICK_SENSITIVITY * 1)
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
@@ -471,7 +496,6 @@ func _on_pick_up_detection_body_entered(body):
if body.is_in_group("pickup"):
if body.pickupable:
body.picked_up()
Input.start_joy_vibration(0,.1,.1,.1)
if body.is_in_group("weapon_pickup"):
weapon_pickup_audio.play()
Input.start_joy_vibration(0,.1,.1,.1)
@@ -496,9 +520,11 @@ func weapon_tilt(input_x, delta):
func weapon_sway(delta):
if !ads:
var joy_input = Vector2(Input.get_joy_axis(0,JOY_AXIS_RIGHT_X)*5,Input.get_joy_axis(0,JOY_AXIS_RIGHT_Y)*5)
mouse_input = lerp(mouse_input, Vector2.ZERO, 10 * delta)
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, mouse_input.y * weapon_sway_amount, 5 * delta)
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, mouse_input.x * weapon_sway_amount, 5 * delta)
joy_input = lerp(joy_input,Vector2.ZERO,10 * delta)
weapon_holder.rotation.x = lerp(weapon_holder.rotation.x, (mouse_input.y + joy_input.y) * weapon_sway_amount, 5 * delta)
weapon_holder.rotation.y = lerp(weapon_holder.rotation.y, (mouse_input.x + joy_input.x) * weapon_sway_amount, 5 * delta)
func weapon_bob(vel : float, delta):
if weapon_holder: