I want to make my spawned objects (enemy prefabs) movement speed up every 10 points my player collects. This is my movement script, attached to my enemy prefab (so that it can be spawned in my game and move):
public static int movespeed = 20;
public Vector3 userDirection = Vector3.right;
public void Update()
{
transform.Translate(userDirection * movespeed * Time.deltaTime);
}
}
And this is my score script attached to my player:
public Text ScoreText;
public AudioClip Coinsound;
public Text Highscoretext;
public GameObject enemy;
Movement movement;
private int Score;
public int highScore = 0;
void Start ()
{
Score = 0;
SetScoreText ();
if (PlayerPrefs.HasKey ("Highscore"))
{
highScore = PlayerPrefs.GetInt("Highscore");
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag ("Pick Up")) {
other.gameObject.SetActive (false);
Score = Score + 1;
SetScoreText ();
AudioSource.PlayClipAtPoint (Coinsound, transform.position);
}
}
As mentioned before I want to make my spawned enemy prefabs to move faster when my player collects every ten points. Thank you :)