// Update is called once per frame void Update() { float distance = Mathf.Abs(Vector3.Distance(transform.position, initialPosition)); if (distance < stats.GetRange()) { transform.position = transform.position + projectileDirection * stats.GetProjectileSpeed() * Time.deltaTime; } }
// Update is called once per frame void Update() { float distance = Mathf.Abs(Vector3.Distance(transform.position, initialPosition)); if (distance >= stats.GetRange()) { explosionArea.enabled = true; StartCoroutine(DestroyAfterTime(stats.GetExplosionPersistTime())); } }