@onready var shotgun_pattern: Path2D = $shotgun_pattern @export var split_damage: bool = false ## Distance between camera and our imaginary plane @export var shot_spread : float @export var vertical_randomness_shot : float @export var horizontal_randomness_shot : float var spray_vector: Curve2D func _ready() -> void: spray_vector = shotgun_pattern.get_curve() return super._ready() func _set_projectile(_damage: int = 0, _spread:Vector2 = Vector2.ZERO, _Range: int = 1000) -> void: randomize() damage = _damage/(max(spray_vector.get_point_count()*float(split_damage),1)) for point: int in spray_vector.get_point_count(): var p: Vector2 = spray_vector.get_point_position(point) var point_on_plane: Vector3 = Vector3(p.x, -p.y, -shot_spread) var ray_to_point: Vector3 = point_on_plane.normalized() var offset: Quaternion = Quaternion(Vector3.FORWARD, ray_to_point) fire_projectile(Vector2(vertical_randomness_shot,horizontal_randomness_shot), _Range, rigid_body_projectile, offset)
or share this direct link: