public class Bullet : MonoBehaviour
{
public float speed;
Vector3 bulletEndPos;
[SerializeField] Controller player;
void Start()
{
player = GameObject.Find("Player").GetComponent<Controller>();
bulletEndPos = transform.position + transform.forward * player.trailDistance;
}
void FixedUpdate()
{
transform.Translate(Vector3.forward * speed * Time.deltaTime);
if (transform.position == bulletEndPos)
{
Destroy(this.gameObject);
}
}