Add hit component and effects; update player and enemy scenes to integrate hit feedback
This commit is contained in:
@@ -7,9 +7,13 @@ extends Node
|
||||
@export var acceleration: float = 8.0
|
||||
@export var detection_area: Area2D
|
||||
@export var max_turn_rate: float = 180.0
|
||||
@export var wobble_strength := 5.0 # degrees
|
||||
@export var drag := 0.98
|
||||
@export var steering_lerp := 0.05 # low = sluggish
|
||||
|
||||
var target: Node2D = null
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
var steering_direction: Vector2 = velocity.normalized()
|
||||
var target: Node2D = null
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -33,11 +37,19 @@ func _physics_process(delta: float) -> void:
|
||||
root.position += velocity * delta
|
||||
return
|
||||
|
||||
var to_target := (target.global_position - root.global_position).normalized()
|
||||
var angle_to_target := velocity.angle_to(to_target)
|
||||
var to_target := (target.global_position - root.global_position).normalized()
|
||||
steering_direction = steering_direction.lerp(to_target, steering_lerp)
|
||||
|
||||
var angle_to_target := velocity.angle_to(steering_direction)
|
||||
var max_angle := deg_to_rad(max_turn_rate) * delta
|
||||
var clamped_angle = clamp(angle_to_target, - max_angle, max_angle)
|
||||
velocity = velocity.rotated(clamped_angle).normalized() * velocity.length()
|
||||
|
||||
var wobble := deg_to_rad(randf_range(-wobble_strength, wobble_strength))
|
||||
clamped_angle += wobble
|
||||
|
||||
velocity = velocity.rotated(clamped_angle)
|
||||
|
||||
velocity *= drag
|
||||
|
||||
var desired_speed = min(max_speed, velocity.length() + acceleration * delta)
|
||||
velocity = velocity.normalized() * desired_speed
|
||||
|
Reference in New Issue
Block a user