set up controller look

This commit is contained in:
Derek
2024-12-08 22:14:22 -06:00
parent bfce40cdc1
commit 81f86396e0
6 changed files with 45 additions and 7 deletions

View File

@@ -1,10 +1,9 @@
[gd_scene load_steps=9 format=3 uid="uid://br882tlh3cfwu"]
[gd_scene load_steps=8 format=3 uid="uid://br882tlh3cfwu"]
[ext_resource type="Script" path="res://scripts/hud.gd" id="1_7hukm"]
[ext_resource type="Theme" uid="uid://clek42ofxr45f" path="res://DefaultTheme.tres" id="1_22trs"]
[ext_resource type="Texture2D" uid="uid://b8r7mp1r4xqv1" path="res://assets/UI/Edit Files/0.5x/Stamina_White@0.5x.png" id="3_2injg"]
[ext_resource type="Texture2D" uid="uid://mcay8s80071h" path="res://assets/UI/Crosshair/SVG/Reticle 1_svg.svg" id="3_tmj0x"]
[ext_resource type="Script" path="res://scripts/UIScreenAdjust.gd" id="4_lbnof"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2hn4h"]
bg_color = Color(0, 0, 0, 0.25098)
@@ -114,7 +113,6 @@ offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("3_tmj0x")
script = ExtResource("4_lbnof")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1

View File

@@ -129,6 +129,7 @@ scroll_down={
escape={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":6,"pressure":0.0,"pressed":true,"script":null)
]
}
interact={
@@ -200,6 +201,7 @@ crouch={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":99,"location":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":8,"pressure":0.0,"pressed":true,"script":null)
]
}
kill_self={

View File

@@ -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)

View File

@@ -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)

View File

@@ -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

View File

@@ -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,6 +174,8 @@ 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)
@@ -175,6 +183,7 @@ func _input(event) -> void:
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
mouse_input = event.relative
func _physics_process(delta):
if !dead and !level_control.paused:
@@ -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():