started fixing hud to prevent crosshair from wobbling
This commit is contained in:
@@ -476,7 +476,6 @@ func _physics_process(delta):
|
||||
joypad_look()
|
||||
aim_down_sights(delta)
|
||||
flashlight_toggle()
|
||||
hud_wobble(delta)
|
||||
hold_item(delta)
|
||||
move_and_slide()
|
||||
crouch(delta)
|
||||
@@ -591,23 +590,6 @@ func aim_down_sights(delta):
|
||||
else:
|
||||
gun.position = lerp(gun.position, weapon_start_pos,(delta * 100)/Engine.time_scale)
|
||||
|
||||
func hud_wobble(delta):
|
||||
var viewport_height_adj = (get_viewport().size.y/1080)
|
||||
|
||||
var HUD_WOBBLE_MAX : float = 40 * viewport_height_adj
|
||||
var MOUSE_AMT = 10 * viewport_height_adj
|
||||
var VELOCITY_AMT = 100 * viewport_height_adj
|
||||
var HUD_SPEED = 10 * viewport_height_adj
|
||||
|
||||
var dir_mouse = Vector2(-mouse_input.x * MOUSE_AMT,-mouse_input.y * MOUSE_AMT)
|
||||
var velocity_dir_transformed = velocity.normalized() * global_basis
|
||||
var velocity_lengh_clamped = clamp(velocity.length(),-VELOCITY_AMT,VELOCITY_AMT)
|
||||
var dir_velocity = Vector2(-velocity_dir_transformed.x * velocity_lengh_clamped,velocity_dir_transformed.y * velocity_lengh_clamped)
|
||||
var dir_clamped = clamp(dir_mouse + dir_velocity,Vector2(-HUD_WOBBLE_MAX,-HUD_WOBBLE_MAX),Vector2(HUD_WOBBLE_MAX,HUD_WOBBLE_MAX))
|
||||
var offset = lerp(hud.position, dir_clamped, delta * HUD_SPEED)
|
||||
hud.position = offset
|
||||
hud.crosshair.position = -offset
|
||||
|
||||
func grab_moveable(body):
|
||||
held_item_cache = {
|
||||
"gravity_scale" : body.gravity_scale
|
||||
|
||||
Reference in New Issue
Block a user