i am making a top down shooter game and i want a upgrade system to buy upgrades you would need upgradepoints i want the player to get them every 1000 score so i would want a script that does it every 1000, 2000, 3000, 4000 … i found something but it did not work please help here is my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class movement : MonoBehaviour {
//Rotate
private Vector3 mouse_pos;
public Transform target;
private Vector3 object_pos;
private float angle;
//Shooting
public float Shootspeed = 3;
private float _shootspeed;
public GameObject Bullet;
//Die
public GameObject DeadScreen;
//upgrades
public float upgradepoints;
public Text pointstext;
//multishot
public float multishotlvl = 0f;
void Update () {
//Rotate
mouse_pos = Input.mousePosition;
mouse_pos.z = -20;
object_pos = Camera.main.WorldToScreenPoint(target.position);
mouse_pos.x = mouse_pos.x - object_pos.x;
mouse_pos.y = mouse_pos.y - object_pos.y;
angle = Mathf.Atan2(mouse_pos.y, mouse_pos.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0, 0, angle);
//Shoot
if (Input.GetMouseButton(0))
{
_shootspeed = _shootspeed - Time.deltaTime;
if (_shootspeed <= 0)
{
Instantiate(Bullet, transform.position, transform.rotation);
_shootspeed = Shootspeed;
//Multishot upgrades \/
if (multishotlvl >= 1)
{
GameObject projectile2 = Instantiate(Bullet, transform.position, transform.rotation);
projectile2.transform.Rotate(transform.rotation.x, transform.rotation.y, transform.rotation.z - 18f);
}
if (multishotlvl >= 2)
{
GameObject projectile3 = Instantiate(Bullet, transform.position, transform.rotation);
projectile3.transform.Rotate(transform.rotation.x, transform.rotation.y, transform.rotation.z + 18f);
}
}
}
//upgrades
int tmp = (int)Scores.Score % 200;
if (tmp == 0 || tmp == 100)
{
Debug.Log("addpoints");
}
if (multishotlvl >= 3)
{
Debug.Log("Alreadymaxed");
}
else
{
if (Input.GetKey(KeyCode.Alpha1))
{
if (upgradepoints >= 1)
{
upgradepoints = upgradepoints - 1;
multishotlvl = multishotlvl + 1;
}
}
}
}
//Die if hit thing tagged enemy
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Enemy")
{
Debug.Log("Player Died By " + collision.gameObject.name);
Die();
}
}
public void Die()
{
DeadScreen.SetActive(true);
Vector3 deadpos = transform.position;
deadpos.x = 9999;
transform.Translate(deadpos);
}
}
Here is the problem
int tmp = (int)Scores.Score % 200;
if (tmp == 0 || tmp == 100)
{
Debug.Log("addpoints");
}
if (multishotlvl >= 3)
{
Debug.Log("Alreadymaxed");
}
else
{
if (Input.GetKey(KeyCode.Alpha1))
{
if (upgradepoints >= 1)
{
upgradepoints = upgradepoints - 1;
multishotlvl = multishotlvl + 1;
}
}
}
}