Godot Version
godot 4.2-stable
Question
how do i make my gun recoil work i tried the following code but it feels snappy underwhelming
this is the code :
func handle_input(delta):
if Input.is_action_just_pressed(“shoot”) and can_shoot == true:
velocity.x += 1000 * knock_back_dir_x
velocity.y += 350 * knock_back_dir_y
can_shoot = false
$gun_timer.start()
func _move_weapon():
var angle = get_local_mouse_position().angle()
weapon.position.x = cos(angle) * weapon_distance
weapon.position.y = sin(angle) * weapon_distance
weapon.rotation = angle
if weapon.position.x < 0 :
$weapon_pos/sawed_shotgun/Sprite2D.flip_v = true
knock_back_dir_x = 1
else:
$weapon_pos/sawed_shotgun/Sprite2D.flip_v = false
knock_back_dir_x = -1
if weapon.position.y < 0 :
knock_back_dir_y = 1
else:
knock_back_dir_y = -1