paratate/systems/bullets/behaviors/simple_linear_behavior.gd

15 lines
537 B
GDScript

class_name SimpleLinearBehavior
extends BulletBehavior
## Makes bullets move in [member Bullet.direction], potentially accelerating.
## Initial speed of the bullet when it is spawned.
@export_custom(0, "suffix:px/s") var initial_speed: float = 0.0
## Rate at which the bullet will speed up.
@export_custom(0, "suffix:px/s²") var acceleration: float = 0.0
func process_bullet(bullet: Bullet, delta: float) -> void:
var speed = initial_speed + acceleration * bullet.time_elapsed
bullet.position += bullet.direction * speed * delta