void Start()
{
target = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
Speed = Mathf.Lerp(speedScaling.x, speedScaling.y, Difficulty.GetDifficultyPercentage());
visibleThreshold = -Camera.main.orthographicSize - transform.localScale.y;
}
// Update is called once per frame
void Update()
{
FollowTarget();
transform.Translate(Vector3.down * Speed * Time.deltaTime);
if(transform.position.y < visibleThreshold)
{
Destroy(gameObject);
}
}
void FollowTarget()
{
transform.position = Vector2.MoveTowards(transform.position, target.position, Speed * Time.deltaTime);
}
I managed to make this projectile follow the target but not what i wanted to