improve projectile trail and player attack
This commit is contained in:
parent
7474427c86
commit
7ba9a7625a
@ -2,10 +2,10 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://bbd22tc1scoom" path="res://scripts/entities/projectiles/projectile.gd" id="1_kv6x5"]
|
||||
[ext_resource type="PackedScene" uid="uid://c8gqrealje3o" path="res://scenes/effects/shadow_decal.tscn" id="3_2dqcj"]
|
||||
[ext_resource type="PackedScene" uid="uid://jmtp1qxxnyr2" path="res://scenes/entities/projectiles/projectile_hit_particles.tscn" id="3_a8d2p"]
|
||||
[ext_resource type="PackedScene" uid="uid://jmtp1qxxnyr2" path="res://scenes/effects/projectiles/projectile_hit_particles.tscn" id="3_a8d2p"]
|
||||
[ext_resource type="PackedScene" uid="uid://bl3flu6un3op1" path="res://assets/models/entities/projectiles/projectile.glb" id="3_oc4rm"]
|
||||
[ext_resource type="Material" uid="uid://dnyl326cg2rvh" path="res://resources/materials/projectiles/projectile_mat.tres" id="4_u2n0m"]
|
||||
[ext_resource type="PackedScene" uid="uid://biq8bu0rbjfgd" path="res://scenes/entities/projectiles/projectile_destroy_particles.tscn" id="4_wq63x"]
|
||||
[ext_resource type="PackedScene" uid="uid://biq8bu0rbjfgd" path="res://scenes/effects/projectiles/projectile_destroy_particles.tscn" id="4_wq63x"]
|
||||
[ext_resource type="Material" uid="uid://d3f5sarakjtlg" path="res://resources/materials/projectiles/projectile_glow_mat.tres" id="5_fdcqu"]
|
||||
[ext_resource type="Material" uid="uid://btoktsgqj62ei" path="res://resources/materials/projectiles/projectile_trail_mat.tres" id="7_j3t3l"]
|
||||
|
||||
@ -32,7 +32,7 @@ material = ExtResource("7_j3t3l")
|
||||
size = Vector2(0.4, 0.4)
|
||||
orientation = 1
|
||||
|
||||
[node name="Projectile" type="Area3D" node_paths=PackedStringArray("_model_base", "_model_mesh")]
|
||||
[node name="Projectile" type="Area3D" node_paths=PackedStringArray("_model_base", "_model_mesh", "_trail_particles")]
|
||||
collision_layer = 32
|
||||
collision_mask = 49
|
||||
script = ExtResource("1_kv6x5")
|
||||
@ -40,6 +40,7 @@ _hit_particles_scene = ExtResource("3_a8d2p")
|
||||
_destroy_particles_scene = ExtResource("4_wq63x")
|
||||
_model_base = NodePath("Model")
|
||||
_model_mesh = NodePath("Model/ProjectileMesh")
|
||||
_trail_particles = NodePath("TrailParticles")
|
||||
|
||||
[node name="Model" parent="." instance=ExtResource("3_oc4rm")]
|
||||
|
||||
@ -68,6 +69,7 @@ amount = 5
|
||||
lifetime = 0.4
|
||||
fixed_fps = 60
|
||||
interpolate = false
|
||||
fract_delta = false
|
||||
visibility_aabb = AABB(-0.4, -0.4, -0.4, 0.8, 0.8, 0.8)
|
||||
process_material = SubResource("ParticleProcessMaterial_fdcqu")
|
||||
draw_pass_1 = SubResource("QuadMesh_fdcqu")
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user