add attack swoosh effect

This commit is contained in:
2025-02-18 03:38:56 +10:00
parent 80b7881cc6
commit 0b7e636c86
8 changed files with 65 additions and 15 deletions

View File

@@ -24,7 +24,9 @@ func _process(_delta: float) -> void:
call_deferred("_mouse_aiming")
_process_respawning()
Debugger.marker("aim", global_position + aiming.aim_offset)
var aim_pos := global_position + aiming.aim_offset
Debugger.marker("aim", aim_pos + Vector3.UP)
Debugger.vector("aimv", Vector3(aim_pos.x, 0, aim_pos.z), aim_pos + Vector3.UP)
func _physics_process(delta: float) -> void:

View File

@@ -29,7 +29,9 @@ func controller_aiming(move_input: Vector2) -> void:
)
func mouse_aiming(mouse_pos: Vector2, player_position: Vector3, is_on_floor: bool) -> void:
func mouse_aiming(
mouse_pos: Vector2, player_position: Vector3, is_on_floor: bool
) -> void:
if Inputer.mode != Inputer.Mode.KB_MOUSE:
return
@@ -38,12 +40,13 @@ func mouse_aiming(mouse_pos: Vector2, player_position: Vector3, is_on_floor: boo
_floor_height = player_position.y
player_position.y = _floor_height
var aim_position := _mouse_project(mouse_pos, _floor_height)
var aim_position := _mouse_project(mouse_pos, _floor_height + Projectile.HEIGHT)
aim_offset = aim_position - player_position
aim_offset.y = 0
aim_position.y = position_y
func _mouse_project(mouse_pos:Vector2, height: float) -> Vector3:
func _mouse_project(mouse_pos: Vector2, height: float) -> Vector3:
var camera := Referencer.main_camera
var from := camera.project_ray_origin(mouse_pos)

View File

@@ -3,16 +3,24 @@ extends Area3D
signal attacked
const SWOOP_EFFECT_TIME: float = 0.25
@export var _collision_debug_material: Material
@export var _attack_max_angle: float = PI / 2
var _debug_collision_shapes := DebugCollisionShapes.new()
var _swoop_effect_timer: float
@onready var _swoop_mesh: MeshInstance3D = $SwoopMesh
func _ready() -> void:
_debug_collision_shapes.init(get_children(), self, _collision_debug_material)
Debugger.add_event("attacked")
attacked.connect(func() -> void: Debugger.event_emitted("attacked", []))
body_entered.connect(_on_body_entered)
position.y = Projectile.HEIGHT
func _unhandled_input(event: InputEvent) -> void:
@@ -20,11 +28,33 @@ func _unhandled_input(event: InputEvent) -> void:
_attack()
func _process(delta: float) -> void:
if _swoop_effect_timer >= 0:
_swoop_effect_timer -= delta
else:
_swoop_effect_timer = 0
(_swoop_mesh.material_override as StandardMaterial3D).albedo_color = Color(
1, 1, 1, _swoop_effect_timer / SWOOP_EFFECT_TIME
)
func _physics_process(_delta: float) -> void:
monitoring = Input.is_action_just_pressed("attack")
func _attack() -> void:
attacked.emit()
_swoop_effect_timer = SWOOP_EFFECT_TIME
func _hit_projectile(projectile: Projectile) -> void:
var diff := projectile.global_position - global_position
diff.y = 0
var angle := global_basis.z.angle_to(diff)
Debugger.vector("ASDSAD", global_position, global_position + global_basis.z)
Debugger.vector("ASDSAD2", global_position, global_position + diff)
if angle > _attack_max_angle:
return
projectile.queue_free()