add attack swoosh effect
This commit is contained in:
parent
80b7881cc6
commit
0b7e636c86
@ -20,10 +20,9 @@ _velocity = Vector3(0, 0, -5)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
mesh = SubResource("BoxMesh_860q6")
|
||||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="MeshInstance3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.552548, -0.339801)
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 1, -0.34)
|
||||
mesh = SubResource("CylinderMesh_esok8")
|
||||
skeleton = NodePath("../..")
|
||||
|
||||
[node name="Marker3D" type="Marker3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.036, -0.590804)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -0.591)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://b73y71y3efmv"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://b73y71y3efmv"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/player/player.gd" id="1_xt3i8"]
|
||||
[ext_resource type="Material" uid="uid://cc18ee0wbfoud" path="res://resources/materials/debug/debug_player.tres" id="2_0p422"]
|
||||
@ -14,9 +14,17 @@ height = 1.8
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_fdktb"]
|
||||
size = Vector3(0.5, 0.5, 0.5)
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_5qjrf"]
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_qsqht"]
|
||||
height = 0.43
|
||||
radius = 2.0
|
||||
height = 6.0
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_m1xj5"]
|
||||
transparency = 1
|
||||
|
||||
[sub_resource type="SphereMesh" id="SphereMesh_kqbjh"]
|
||||
radius = 2.0
|
||||
height = 2.0
|
||||
is_hemisphere = true
|
||||
|
||||
[node name="Player" type="CharacterBody3D"]
|
||||
collision_layer = 16
|
||||
@ -36,11 +44,16 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.17779, 0.357218)
|
||||
mesh = SubResource("BoxMesh_fdktb")
|
||||
|
||||
[node name="AttackArea" type="Area3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
collision_layer = 32
|
||||
collision_mask = 32
|
||||
script = ExtResource("3_8pbtx")
|
||||
_collision_debug_material = ExtResource("4_ll2ct")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="AttackArea"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("CapsuleShape3D_5qjrf")
|
||||
shape = SubResource("CylinderShape3D_qsqht")
|
||||
|
||||
[node name="SwoopMesh" type="MeshInstance3D" parent="AttackArea"]
|
||||
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -0.0985078, 0, 1, -4.30591e-09, 0, 0, 0)
|
||||
material_override = SubResource("StandardMaterial3D_m1xj5")
|
||||
mesh = SubResource("SphereMesh_kqbjh")
|
||||
|
||||
@ -11,7 +11,7 @@ radius = 0.25
|
||||
height = 0.5
|
||||
|
||||
[node name="Projectile" type="AnimatableBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.535, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
collision_layer = 32
|
||||
collision_mask = 32
|
||||
script = ExtResource("1_kv6x5")
|
||||
|
||||
@ -23,7 +23,7 @@ func _follow(delta: float) -> void:
|
||||
var player_position := Referencer.player.global_position
|
||||
if Referencer.player.is_on_floor():
|
||||
_floor_height = player_position.y
|
||||
player_position.y = _floor_height
|
||||
player_position.y = _floor_height + Projectile.HEIGHT
|
||||
|
||||
if Inputer.mode == Inputer.Mode.KB_MOUSE:
|
||||
_aim_offset = Referencer.player.aiming.aim_offset
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
class_name Projectile
|
||||
extends AnimatableBody3D
|
||||
|
||||
const HEIGHT: float = 1
|
||||
|
||||
@export var _collision_debug_material: Material
|
||||
|
||||
var _start_position: Vector3
|
||||
@ -16,6 +18,7 @@ func _ready() -> void:
|
||||
_life_timer = _lifetime
|
||||
_debug_collision_shapes.init(get_children(), self, _collision_debug_material)
|
||||
global_position = _start_position
|
||||
global_position.y = HEIGHT
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user