Increase spawn object movement when player collects every 10 points
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 :)
Comment
Your answer
Follow this Question
Related Questions
How to move an object with a starting and ending speed and time 0 Answers
Move enemy to a specific movepoint with an array (C#) 1 Answer
How to move an object, depend to a second 0 Answers
Keep object constrained to z space origin 1 Answer
How can I change the design of game_object at runtime? 0 Answers