improve projectile trail and player attack
This commit is contained in:
@@ -41,7 +41,6 @@ func _ready() -> void:
|
||||
_set_collision_size(attack_radius)
|
||||
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if _cooldown_timer > 0:
|
||||
_cooldown_timer -= delta
|
||||
@@ -137,6 +136,7 @@ func _hit_projectile(projectile: Projectile) -> void:
|
||||
)
|
||||
projectile.hit(new_direction * _hit_projectile_speed)
|
||||
_queue_hit_stop = true
|
||||
did_hit.emit()
|
||||
break
|
||||
|
||||
prev_dir_angle = dir_angle
|
||||
@@ -158,4 +158,3 @@ func _on_area_entered(node: Node3D) -> void:
|
||||
|
||||
if node is Projectile:
|
||||
_hit_projectile(node as Projectile)
|
||||
did_hit.emit()
|
||||
|
||||
@@ -8,10 +8,12 @@ const MAX_STRETCH: float = 0.75
|
||||
|
||||
@export var _hit_particles_scene: PackedScene
|
||||
@export var _destroy_particles_scene: PackedScene
|
||||
@export var _velocity_to_trail_rate: float = 0.5
|
||||
|
||||
@export_group("References")
|
||||
@export var _model_base: Node3D
|
||||
@export var _model_mesh: MeshInstance3D
|
||||
@export var _trail_particles: GPUParticles3D
|
||||
|
||||
var _start_position: Vector3
|
||||
var _velocity: Vector3
|
||||
@@ -39,11 +41,12 @@ func _physics_process(delta: float) -> void:
|
||||
global_position += _velocity * delta
|
||||
look_at(global_position + _velocity, Vector3.UP, true)
|
||||
|
||||
var speed_squash := clampf(
|
||||
_velocity.length() / _speed_stretch_factor, 0, MAX_STRETCH
|
||||
)
|
||||
var speed := _velocity.length()
|
||||
var speed_squash := clampf(speed / _speed_stretch_factor, 0, MAX_STRETCH)
|
||||
_model_base.scale = Vector3(1 - speed_squash, 1 - speed_squash, 1 + speed_squash)
|
||||
|
||||
_trail_particles.amount = int(speed * _velocity_to_trail_rate)
|
||||
|
||||
|
||||
func init(velocity: Vector3, start_position: Vector3, lifetime: float = 10) -> void:
|
||||
_velocity = velocity
|
||||
@@ -71,9 +74,15 @@ func _destroy() -> void:
|
||||
)
|
||||
get_tree().get_root().add_child(destroy_particles)
|
||||
destroy_particles.init(global_position)
|
||||
set_deferred("monitorable", false)
|
||||
set_deferred("monitoring", false)
|
||||
_model_base.visible = false
|
||||
await get_tree().create_timer(5).timeout
|
||||
queue_free()
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_body_entered(node: Node3D) -> void:
|
||||
if node is Player:
|
||||
queue_free()
|
||||
|
||||
Reference in New Issue
Block a user