This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/Scripts/Item/Pistol/BulletComponent.cs
2023-06-01 08:03:48 -07:00

40 lines
908 B
C#

using UnityEngine;
public class BulletComponent : MonoBehaviour
{
[SerializeField] private float duration = 5f;
[SerializeField] private string type = "flare";
[SerializeField] private float damageRange = 20f;
[SerializeField] private float damageMagnitude = 1f;
private float existed;
private FlareRegister register;
public float DamageMagnitude => damageMagnitude;
public float DamageRange => damageRange;
// Start is called before the first frame update
private void Start()
{
register = FlareRegister.instance;
register.bullets.Add(this);
}
// Update is called once per frame
private void Update()
{
}
private void FixedUpdate()
{
if (existed >= duration)
{
register.bullets.Remove(this);
Destroy(gameObject);
}
existed += Time.fixedDeltaTime;
}
}