set up controller look
This commit is contained in:
4
hud.tscn
4
hud.tscn
@@ -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="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="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://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="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"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2hn4h"]
|
||||||
bg_color = Color(0, 0, 0, 0.25098)
|
bg_color = Color(0, 0, 0, 0.25098)
|
||||||
@@ -114,7 +113,6 @@ offset_bottom = 20.0
|
|||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
texture = ExtResource("3_tmj0x")
|
texture = ExtResource("3_tmj0x")
|
||||||
script = ExtResource("4_lbnof")
|
|
||||||
|
|
||||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ scroll_down={
|
|||||||
escape={
|
escape={
|
||||||
"deadzone": 0.5,
|
"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)
|
"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={
|
interact={
|
||||||
@@ -200,6 +201,7 @@ crouch={
|
|||||||
"deadzone": 0.5,
|
"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)
|
"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(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={
|
kill_self={
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ func fire():
|
|||||||
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
audio_fire.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||||
audio_fire.play()
|
audio_fire.play()
|
||||||
pellet_spawn()
|
pellet_spawn()
|
||||||
|
vibration()
|
||||||
fire_smoke.restart()
|
fire_smoke.restart()
|
||||||
fire_smoke.emitting = true
|
fire_smoke.emitting = true
|
||||||
smoke_timer.start()
|
smoke_timer.start()
|
||||||
@@ -142,3 +143,5 @@ func _on_smoke_timer_timeout() -> void:
|
|||||||
smoke.emitting = true
|
smoke.emitting = true
|
||||||
smoke_timer.stop()
|
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.pitch_scale = 1 + rng.randf_range(-fire_pitch_scale_amt,fire_pitch_scale_amt)
|
||||||
audio_fire.play()
|
audio_fire.play()
|
||||||
anim_player.play("shoot")
|
anim_player.play("shoot")
|
||||||
|
vibration()
|
||||||
bullet_fire()
|
bullet_fire()
|
||||||
hitscan_fire()
|
hitscan_fire()
|
||||||
spawn_casing()
|
spawn_casing()
|
||||||
@@ -169,3 +170,6 @@ func hitscan_fire():
|
|||||||
|
|
||||||
func swapped_out():
|
func swapped_out():
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
func vibration():
|
||||||
|
Input.start_joy_vibration(0,.1,.5,.1)
|
||||||
|
|||||||
@@ -38,7 +38,13 @@ func _ready() -> void:
|
|||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
player = level_control.player
|
player = level_control.player
|
||||||
if player != null:
|
if player != null:
|
||||||
|
#HEALTH
|
||||||
health_bar.value = level_control.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)
|
money.text = "$" + str(level_control.money)
|
||||||
if player.remaining_stamina/player.MAX_STAMINA >= .99:
|
if player.remaining_stamina/player.MAX_STAMINA >= .99:
|
||||||
stam_bar_visible = false
|
stam_bar_visible = false
|
||||||
@@ -61,6 +67,7 @@ func _process(delta: float) -> void:
|
|||||||
change_color(crosshair,FULL_WHITE,10,delta)
|
change_color(crosshair,FULL_WHITE,10,delta)
|
||||||
|
|
||||||
if player.interact_ray.is_colliding():
|
if player.interact_ray.is_colliding():
|
||||||
|
if player.interact_ray.get_collider() != null:
|
||||||
if player.interact_ray.get_collider().is_in_group("interact"):
|
if player.interact_ray.get_collider().is_in_group("interact"):
|
||||||
interact_visible = true
|
interact_visible = true
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ const STAMINA_DRAIN = 20
|
|||||||
const BOB_FREQ = 1.7
|
const BOB_FREQ = 1.7
|
||||||
const BOB_AMP = 0.1
|
const BOB_AMP = 0.1
|
||||||
const ADS_POS = Vector3(0,-.05,-.45)
|
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 speed
|
||||||
var double_jump = true
|
var double_jump = true
|
||||||
var air_dash = MAX_AIR_DASH
|
var air_dash = MAX_AIR_DASH
|
||||||
@@ -168,6 +174,8 @@ func _input(event) -> void:
|
|||||||
head.rotate_x(-event.relative.y * SENSITIVITY)
|
head.rotate_x(-event.relative.y * SENSITIVITY)
|
||||||
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||||
mouse_input = event.relative
|
mouse_input = event.relative
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
self.rotate_y(event.relative.x * .00001)
|
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))
|
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-90), deg_to_rad(85))
|
||||||
mouse_input = event.relative
|
mouse_input = event.relative
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
|
|
||||||
if !dead and !level_control.paused:
|
if !dead and !level_control.paused:
|
||||||
@@ -393,6 +402,7 @@ func _physics_process(delta):
|
|||||||
if level_control.health <= 0:
|
if level_control.health <= 0:
|
||||||
level_control.die()
|
level_control.die()
|
||||||
|
|
||||||
|
joypad_look(delta)
|
||||||
aim_down_sights(delta)
|
aim_down_sights(delta)
|
||||||
flashlight_toggle()
|
flashlight_toggle()
|
||||||
hold_item(delta)
|
hold_item(delta)
|
||||||
@@ -402,6 +412,18 @@ func _physics_process(delta):
|
|||||||
weapon_sway(delta)
|
weapon_sway(delta)
|
||||||
weapon_bob(velocity.length(), 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():
|
func flashlight_toggle():
|
||||||
if flashlight_on:
|
if flashlight_on:
|
||||||
flashlight.light_energy = FLASHLIGHT_BRIGHTNESS
|
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.is_in_group("pickup"):
|
||||||
if body.pickupable:
|
if body.pickupable:
|
||||||
body.picked_up()
|
body.picked_up()
|
||||||
|
Input.start_joy_vibration(0,.1,.1,.1)
|
||||||
if body.is_in_group("weapon_pickup"):
|
if body.is_in_group("weapon_pickup"):
|
||||||
weapon_pickup_audio.play()
|
weapon_pickup_audio.play()
|
||||||
|
Input.start_joy_vibration(0,.1,.1,.1)
|
||||||
|
|
||||||
|
|
||||||
func ladder_collide():
|
func ladder_collide():
|
||||||
|
|||||||
Reference in New Issue
Block a user