Quantcast
Channel: Questions in topic: "namespace"
Viewing all articles
Browse latest Browse all 398

error CS0118: 'Player' is a 'namespace' but a 'type' was expected

$
0
0
using System.Collections; using System.Collections.Generic; using UnityEngine; using Player ; namespace Player { public class MonoBehaviour { Player pl1 = new Player (); GameObject [] pauseObjects; GameObject [] finishObjects; //player Player; void OnTriggerEnter2D(Collider2D other){ if(other.gameObject.tag == "Player"){ other.gameObject.GetComponent().alive = false; Time.timeScale = 0; } } void Start () { Time.timeScale = 1; pauseObjects = GameObject.FindGameObjectsWithTag("ShowOnPause"); //gets all objects with tag ShowOnPause finishObjects = GameObject.FindGameObjectsWithTag("ShowOnFinish"); //gets all objects with tag ShowOnFinish hidePaused(); hideFinished(); //Checks to make sure MainLevel is the loaded level if(Application.loadedLevelName == "MainLevel") playerController = GameObject.FindGameObjectWithTag("Player").GetComponent(); } void Update () { if(Input.GetKeyDown(KeyCode.P)) { if(Time.timeScale == 1 && player.alive == true) { Time.timeScale = 0; showPaused(); } else if (Time.timeScale == 0 && player.alive == true){ Time.timeScale = 1; hidePaused(); } } } public void Reload(){ Application.LoadLevel(Application.loadedLevel); } public void pauseControl(){ if(Time.timeScale == 1) { Time.timeScale = 0; showPaused(); } else if (Time.timeScale == 0){ Time.timeScale = 1; hidePaused(); } } public void showPaused(){ foreach(GameObject g in pauseObjects){ g.SetActive(true); } } //hides objects with ShowOnPause tag public void hidePaused(){ foreach(GameObject g in pauseObjects){ g.SetActive(false); } } //shows objects with ShowOnFinish tag public void showFinished(){ foreach(GameObject g in finishObjects){ g.SetActive(true); } } //hides objects with ShowOnFinish tag public void hideFinished(){ foreach(GameObject g in finishObjects){ g.SetActive(false); } } //loads inputted level public void LoadLevel(string level){ Application.LoadLevel(level); } } }

Viewing all articles
Browse latest Browse all 398

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>