set up controller look
This commit is contained in:
@@ -18,6 +18,12 @@ const STAMINA_DRAIN = 20
|
||||
const BOB_FREQ = 1.7
|
||||
const BOB_AMP = 0.1
|
||||
const ADS_POS = Vector3(0,-.05,-.45)
|
||||
|
||||
#JOYSTICK SETTINGS
|
||||
const JOYSTICK_SENSITIVITY = .06
|
||||
var adj_sensitivity = JOYSTICK_SENSITIVITY
|
||||
const JOYSTICK_DEADZONE = 0.05
|
||||
|
||||
var speed
|
||||
var double_jump = true
|
||||
var air_dash = MAX_AIR_DASH
|
||||
@@ -168,12 +174,15 @@ func _input(event) -> void:
|
||||
head.rotate_x(-event.relative.y * SENSITIVITY)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
mouse_input = event.relative
|
||||
|
||||
|
||||
else:
|
||||
if event is InputEventMouseMotion:
|
||||
self.rotate_y(event.relative.x * .00001)
|
||||
head.rotate_x(event.relative.y * .00001)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
mouse_input = event.relative
|
||||
|
||||
|
||||
func _physics_process(delta):
|
||||
|
||||
@@ -393,6 +402,7 @@ func _physics_process(delta):
|
||||
if level_control.health <= 0:
|
||||
level_control.die()
|
||||
|
||||
joypad_look(delta)
|
||||
aim_down_sights(delta)
|
||||
flashlight_toggle()
|
||||
hold_item(delta)
|
||||
@@ -402,6 +412,18 @@ func _physics_process(delta):
|
||||
weapon_sway(delta)
|
||||
weapon_bob(velocity.length(), delta)
|
||||
|
||||
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:
|
||||
self.rotate_y(-xAxis * JOYSTICK_SENSITIVITY * 1)
|
||||
if abs(yAxis) > JOYSTICK_DEADZONE:
|
||||
head.rotate_x(-yAxis * JOYSTICK_SENSITIVITY * 1)
|
||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||
|
||||
func flashlight_toggle():
|
||||
if flashlight_on:
|
||||
flashlight.light_energy = FLASHLIGHT_BRIGHTNESS
|
||||
@@ -447,8 +469,10 @@ 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)
|
||||
|
||||
|
||||
func ladder_collide():
|
||||
|
||||
Reference in New Issue
Block a user