class_name RifleBeam
extends Node3D

@export var endpoint: Vector3

@onready var mesh: MeshInstance3D = $Mesh


# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	var length: float = (endpoint - global_position).length()
	mesh.position.z = -length / 2.0
	var cylinder: CylinderMesh = mesh.mesh
	cylinder.height = length

	(cylinder.material as ShaderMaterial).set_shader_parameter("y_scale", length)
