add kick system

This commit is contained in:
2026-04-22 17:44:54 +03:00
parent 0a637a6160
commit 8a6ecf3f45
4 changed files with 80 additions and 13 deletions
+16 -9
View File
@@ -4,15 +4,14 @@ enum State { IDLE, FLYING }
const AIR_FRICTION := 0.84
const MIN_SPEED := 0.5
const DAMAGE_MULT := 0.9
const WALL_BOUNCE := 0.5
const WALL_SELF_DMG := 0.6
const HIT_SELF_DMG := 0.4
var state: State = State.IDLE
var fly_vel: Vector3 = Vector3.ZERO
var health: float = 60.0
var dead: bool = false
var damage_modifier: float = 1.25
@onready var mesh_node: MeshInstance3D = $RockMesh
var rock_mat: StandardMaterial3D
@@ -25,6 +24,12 @@ func _ready() -> void:
rock_mat = mesh_node.material_override.duplicate() as StandardMaterial3D
mesh_node.material_override = rock_mat
func can_merge_with(_other: Node3D, _speed: float) -> bool:
return false
func apply_collision_damage(dmg: float) -> void:
_take_damage(dmg)
func receive_kick(direction: Vector3, force: float) -> void:
fly_vel = direction * force
fly_vel.y = 0.0
@@ -57,14 +62,16 @@ func _fly(delta: float) -> void:
_take_damage(speed_now * WALL_SELF_DMG)
handled = true
break
elif col3d.is_in_group("enemies"):
var to_enemy := col3d.global_position - global_position
to_enemy.y = 0.0
var dir := to_enemy.normalized() if to_enemy.length() > 0.01 else (fly_vel.normalized() if fly_vel.length() > 0.01 else Vector3.FORWARD)
col3d.call("_take_hit", int(speed_now * DAMAGE_MULT))
col3d.call("receive_kick", dir, speed_now * 0.65)
elif col3d.is_in_group("enemies") or col3d.is_in_group("rocks"):
if col3d == self:
continue
KickSystem.resolve(self, col3d, fly_vel)
if not dead and is_instance_valid(col3d):
var kick_dir := col3d.global_position - global_position
kick_dir.y = 0.0
if kick_dir.length() > 0.01:
col3d.call("receive_kick", kick_dir.normalized(), speed_now * 0.65)
fly_vel *= 0.45
_take_damage(speed_now * HIT_SELF_DMG)
handled = true
break