Hey the error is in line #27.
Error:
error CS0246: The type or namespace name `playerScript’ could not be found. Are you missing a using directive or an assembly reference?
Please help me and I would be very happy if if someone could repair the error and send the script back.
Thanks for every answer.
btw. sorry for bad grammar because I am german.
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour
{
//booleans
public bool isCounting = true;
public bool showScoreInTheMiddle;
public bool takeScore;
public bool scoreIsTakable;
public bool upgradable;
public bool notEnoughPointsGUI;
public bool showGUI;
public bool showHealthOnScreen;
// numbers
public float notEnoughPointsGUIShowCounter;
public float timer;
public int requiredPoints;
public int healthInThisScript;
public int score;
public int upgradePoints;
public int hiScore;
private GUIStyle guiStyle = new GUIStyle();
public GameObject DethScreen;
public playerScript pScript; //Here is the error!! The errorcode is: error CS0246: The type or namespace name `playerScript' could not be found. Are you missing a using directive or an assembly reference?
void Start()
{
RetrievePlayerPrefs();
scoreIsTakable = true;
takeScore = false;
GameObject kugel = GameObject.Find("Kugel");
// KugelCollider = scriptname
KugelCollider kugelCollider = kugel.GetComponent<KugelCollider>();
}
void Update()
{
if (isCounting)
{
Counting();
}
if (DethScreen.activeInHierarchy)
{
isCounting = false;
takeScore = true;
showHealthOnScreen = true;
}
else
{
showHealthOnScreen = false;
}
if (takeScore == true)
{
if (scoreIsTakable == true)
{
upgradePoints = upgradePoints + score;
scoreIsTakable = false;
}
}
//I got the tip to assign health to the specific instance of the script (I think I have to do it in the Inspector but because of the error it doesnt work to assign it)
pScript.health = healthInThisScript;
if (upgradePoints >= requiredPoints)
{
upgradable = true;
}
else
{
upgradable = false;
}
UpdatePlayerPrefsPoints();
if (score > hiScore)
{
UpdatePlayerPrefsHighScore();
}
if (DethScreen.activeInHierarchy)
{
showScoreInTheMiddle = true;
}
if (notEnoughPointsGUI == true)
{
notEnoughPointsGUIShowCounter += 1f;
showGUI = true;
notEnoughPointsGUI = false;
}
else
{
notEnoughPointsGUIShowCounter = 0;
}
if (notEnoughPointsGUIShowCounter >= 3)
{
showGUI = false;
}
}
void Counting()
{
timer += Time.deltaTime;
if (timer > 1f)
{
score += 1;
timer -= 1f;
}
}
void RetrievePlayerPrefs()
{
hiScore = PlayerPrefs.GetInt("HighScore");
requiredPoints = PlayerPrefs.GetInt("requiredPoints");
upgradePoints = PlayerPrefs.GetInt("upgradePoints");
}
void UpdatePlayerPrefsHighScore()
{
hiScore = score;
PlayerPrefs.SetInt("HighScore", hiScore);
}
public void UpgradeHealthButton()
{
if (upgradable == true)
{
requiredPoints = requiredPoints * 2;
healthInThisScript += 10;
upgradePoints = upgradePoints - requiredPoints;
}
else
{
notEnoughPointsGUI = true;
}
}
// OLD OnGUI SYSTEM!
// CONSIDER CHANGING TO NEW UI SYSTEM.
// - BUT HOW???
void OnGUI()
{
guiStyle.fontSize = 60;
GUI.Label(new Rect(105, 22, 100, 100), score.ToString(), guiStyle);
GUI.Label(new Rect(205, 22, 100, 100), hiScore.ToString(), guiStyle);
if (showScoreInTheMiddle == true)
{
GUI.Label(new Rect(515, 290, 100, 100), score.ToString(), guiStyle);
}
if (showHealthOnScreen == true)
{
GUI.Label(new Rect(105, 22, 100, 100), pScript.health.ToString(), guiStyle);
GUI.Label(new Rect(105, 22, 100, 100), upgradePoints.ToString(), guiStyle);
}
}
}
//I would be very happy if someone could repair the error and send the script back; THX