using Unity.VisualScripting;
using UnityEngine;
///
/// Should be attached to the Arrow, not the skeleton
///
[RequireComponent(typeof(Rigidbody))]
public class ProjectileHandler : MonoBehaviour
{
[SerializeField] protected float _lifeSpan = 8.0f;
protected Rigidbody RigidBody;
protected bool FromTeamA;
void Awake()
{
RigidBody = GetComponent();
}
void Start()
{
// Destroy after _lifeSpan, in all case
Destroy(this.gameObject, _lifeSpan);
}
void Update()
{
// Align with speed
if (RigidBody.linearVelocity.magnitude >= 1f) transform.forward = RigidBody.linearVelocity.normalized;
}
public void LaunchProjectile(Vector3 baseSpeed, bool fromTeamA)
{
RigidBody.linearVelocity = baseSpeed;
FromTeamA = fromTeamA;
}
}