How to make the bullet power doubled when i enter into a new level??
Look at Unity - Scripting API: SceneManagement.SceneManager.sceneLoaded
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
Debug.Log("OnSceneLoaded: " + scene.name);
Debug.Log(mode);
}
Do something like power = power * 2
ahmm, i have an array of level, the level turns to another level base on the score provided in the array, so i want my enemy and bullets increase the number everytime i get a new level… how is that??
For example i get 10 points, so it turn to level two, so i want my bullets and enemies become doubled,
THIS IS MY CODE FOR THAT
(the level is working fine)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerStats : MonoBehaviour
{
public int currentLevel;
public int[ ] toLevelUpScore;
public Text levelText;
public int currentEnemyCount;
public int[ ] toIncreaseEnemyCount;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (ScoreManager.score >= toLevelUpScore[currentLevel])
{
currentLevel++;
}
levelText.text = "LEVEL: " + currentLevel;
}
public void IncreaseEnemy()
{
if(ScoreManager.score >= toIncreaseEnemyCount[currentEnemyCount])
{
currentEnemyCount++;
}
}
}
CODE FOR INSTANTIATION OF ENEMY
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour {
public GameObject enemy;
public Transform[ ] spawnSpots;
private float timeBtwSpawns;
public float strtTimeBtwSpawns;
private PlayerStats thePlayerStats;
// Use this for initialization
void Start () {
timeBtwSpawns = strtTimeBtwSpawns;
thePlayerStats = FindObjectOfType();
}
// Update is called once per frame
void Update () {
if(timeBtwSpawns <= 0)
{
int randPos = Random.Range(0, spawnSpots.Length);
Instantiate(enemy, spawnSpots[randPos].position, Quaternion.identity);
timeBtwSpawns = strtTimeBtwSpawns;
}else{
timeBtwSpawns -= Time.deltaTime;
}
}
}
CODE FOR INSTANTIATION OF BULLETS
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Shooting : MonoBehaviour
{
public GameObject shot;
private Transform playerPos;
public GameObject playerAnim;
private PlayerStats thePlayerStats;
void Start()
{
playerPos = GetComponent();
thePlayerStats = FindObjectOfType();
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Instantiate(shot, playerPos.position, Quaternion.identity);
}
}
}