set up controller look
This commit is contained in:
@@ -98,6 +98,7 @@ func fire():
|
||||
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||
audio_fire.play()
|
||||
pellet_spawn()
|
||||
vibration()
|
||||
fire_smoke.restart()
|
||||
fire_smoke.emitting = true
|
||||
smoke_timer.start()
|
||||
@@ -142,3 +143,5 @@ func _on_smoke_timer_timeout() -> void:
|
||||
smoke.emitting = true
|
||||
smoke_timer.stop()
|
||||
|
||||
func vibration():
|
||||
Input.start_joy_vibration(0,.5,.9,.2)
|
||||
|
||||
@@ -89,6 +89,7 @@ func shoot(delta):
|
||||
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||
audio_fire.play()
|
||||
anim_player.play("shoot")
|
||||
vibration()
|
||||
bullet_fire()
|
||||
hitscan_fire()
|
||||
spawn_casing()
|
||||
@@ -169,3 +170,6 @@ func hitscan_fire():
|
||||
|
||||
func swapped_out():
|
||||
queue_free()
|
||||
|
||||
func vibration():
|
||||
Input.start_joy_vibration(0,.1,.5,.1)
|
||||
|
||||
@@ -38,7 +38,13 @@ func _ready() -> void:
|
||||
func _process(delta: float) -> void:
|
||||
player = level_control.player
|
||||
if player != null:
|
||||
#HEALTH
|
||||
health_bar.value = level_control.health
|
||||
if level_control.health <= 2:
|
||||
change_color(health_bar,RED_COLOR,10,delta)
|
||||
else:
|
||||
change_color(health_bar,FULL_WHITE,10,delta)
|
||||
#MONEY
|
||||
money.text = "$" + str(level_control.money)
|
||||
if player.remaining_stamina/player.MAX_STAMINA >= .99:
|
||||
stam_bar_visible = false
|
||||
@@ -61,10 +67,11 @@ func _process(delta: float) -> void:
|
||||
change_color(crosshair,FULL_WHITE,10,delta)
|
||||
|
||||
if player.interact_ray.is_colliding():
|
||||
if player.interact_ray.get_collider().is_in_group("interact"):
|
||||
interact_visible = true
|
||||
else:
|
||||
interact_visible = false
|
||||
if player.interact_ray.get_collider() != null:
|
||||
if player.interact_ray.get_collider().is_in_group("interact"):
|
||||
interact_visible = true
|
||||
else:
|
||||
interact_visible = false
|
||||
else:
|
||||
interact_visible = false
|
||||
|
||||
|
||||
@@ -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