Is there a way of limiting my speeding my enemy script every time my player collects 10 points. I have a movement script attached to my enemies and every time my player collects 10 points my enemies get faster. I want to put a limit on that so that the movement script (attached to my enemies) doesn't increase all the time even if the player continue to collect 10 more points and onwards. I want the limit to be 40, so even if the player continues to collect another 10 points the movement should stay at 40.
This is my speeding up my enemies script (this is used in my score script):
if (Score % 10 == 0){ //Increment movespeed variable from Movement script Movement.movespeed += 4; } And this is my movement script attached to my enemies:
public static int movespeed = 20; public Vector3 userDirection = Vector3.right; //public float lifetime; void Start () { //Destroy (gameObject, lifetime); } public void Update() { transform.Translate (userDirection * movespeed * Time.deltaTime); } How can I limit the movement speed so that it doesn't exceed the upper limit I want?