Added follow angle for spread shots so projectiles point in the
direction they're going.
This commit is contained in:
parent
62e02d2555
commit
2db5f37975
3 changed files with 7 additions and 0 deletions
|
|
@ -16,4 +16,5 @@ horizontal_offset = 8.25
|
||||||
spread_angle = 7.5
|
spread_angle = 7.5
|
||||||
stagger_offset = 0.5
|
stagger_offset = 0.5
|
||||||
stagger_animation = true
|
stagger_animation = true
|
||||||
|
follow_angle = true
|
||||||
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
metadata/_custom_type_script = "uid://7n1itonn35fm"
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@ func _process(delta):
|
||||||
var velocity = Vector2.UP.rotated(deg_to_rad(angle)) * shot_data.speed
|
var velocity = Vector2.UP.rotated(deg_to_rad(angle)) * shot_data.speed
|
||||||
position += velocity * delta
|
position += velocity * delta
|
||||||
|
|
||||||
|
# Rotate sprite to face travel direction when conditions are met
|
||||||
|
if shot_data.follow_angle and shot_data.projectiles > 2 and shot_data.spread_angle > 0:
|
||||||
|
$AnimatedSprite2D.rotation = deg_to_rad(angle)
|
||||||
|
|
||||||
func activate():
|
func activate():
|
||||||
is_active = true
|
is_active = true
|
||||||
visible = true
|
visible = true
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,5 @@ extends Resource
|
||||||
@export_category("Effects")
|
@export_category("Effects")
|
||||||
# Offset animation playback per projectile index
|
# Offset animation playback per projectile index
|
||||||
@export var stagger_animation: bool = false
|
@export var stagger_animation: bool = false
|
||||||
|
# Rotate projectiles to point along their travel direction (requires >2 projectiles and spread_angle > 0)
|
||||||
|
@export var follow_angle: bool = false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue