[node name="Player" parent="." instance=ExtResource("1_yhk1e")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -143.826, 0, -132.995)
+squating_noise_mod = 0.5
+running_noise_mod = 1.75
[node name="BaseEnemy" parent="." node_paths=PackedStringArray("player") instance=ExtResource("6_os3o0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -229.93, 0, -72.7142)
# How fast the player moves in meters per second.
@export var speed := 5
@export_range(0, 2) var squating_speed_mod: float = .5
-@export_range(0, 2) var runnig_speed_mod: float = 1.5
+@export_range(0, 2) var running_speed_mod: float = 1.5
# The downward acceleration when in the air, in meters per second squared.
@export var fall_acceleration := 10
@onready var camera := $Camera3D
var target_velocity := Vector3.ZERO
-var noise: int = 0
+var noise: float = 0
const squat_position := 0.6 # Position to which the camera moves when squatting
const stand_position := 1.7 # Position to which the camera moves when standing
func _physics_process(delta):
var direction := Vector3.ZERO
var speed_mod: float = 1
+ var noise_mod: float = 1
if Input.is_action_just_pressed("squat"):
is_squatting = true
elif not is_squatting and camera.position.y < stand_position:
camera.translate(Vector3(0, move_speed * delta, 0))
- if Input.is_action_pressed("run"):
- speed_mod = runnig_speed_mod
if Input.is_action_pressed("squat"):
speed_mod = squating_speed_mod
+ noise_mod = squating_noise_mod
+ elif Input.is_action_pressed("run"):
+ speed_mod = running_speed_mod
+ noise_mod = running_noise_mod
if Input.is_action_pressed("move_right"):
direction += transform.basis.x
# if movement make some noise
if randf() > .95:
- noise = clamp(noise + 1, 0, 9)
+ var add_noise = 1 * noise_mod
+ noise = clamp(noise + add_noise, 0, 9)
set_meta("noise", noise)
target_velocity.x = direction.x * speed * speed_mod