fixed shotgun pellets
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
extends Projectile
|
||||
|
||||
@export var max_bounces : int = 10
|
||||
@export var collision_shape: CollisionShape3D
|
||||
@export var mesh: MeshInstance3D
|
||||
|
||||
@onready var collision_shape: CollisionShape3D = $CollisionShape3D
|
||||
@onready var mesh: MeshInstance3D = $MeshInstance3D
|
||||
@onready var material = mesh.get_surface_override_material(0)
|
||||
|
||||
var bounces = 0
|
||||
var start_time
|
||||
var end_time
|
||||
var despawning = false
|
||||
|
||||
const EMISSION_MAX : float = 200
|
||||
const EMISSION_LIFETIME : float = 1.75 #in seconds
|
||||
@@ -24,19 +25,15 @@ func _process(delta: float) -> void:
|
||||
var current_time = (Time.get_ticks_msec())/end_time
|
||||
material.emission_energy_multiplier = clamp(lerp(EMISSION_MAX,0.0,current_time),0,EMISSION_MAX)
|
||||
|
||||
|
||||
func _on_body_entered(body: Node) -> void:
|
||||
bounces += 1
|
||||
if bounces >= max_bounces:
|
||||
despawn()
|
||||
|
||||
if linear_velocity.length() >= VELOCITY_REQUIRED_TO_HIT:
|
||||
damage(body)
|
||||
if despawning:
|
||||
linear_velocity.y -= .1 * delta
|
||||
|
||||
func despawn():
|
||||
collision_shape.disabled = true
|
||||
await get_tree().create_timer(1).timeout
|
||||
self.queue_free()
|
||||
gravity_scale = 0
|
||||
despawning = true
|
||||
await get_tree().create_timer(2).timeout
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
|
||||
Reference in New Issue
Block a user