Okay so essentially I am trying to make a Door/Debris disappear when I press the E key and have enough points. Here is my code(s)
public int Points;
// Use this for initialization
void Start ()
{
Points = 500;
}
public void AddPoints(int PointsToAdd)
{
Points += PointsToAdd;
}
public void MinusPoints(int PointsToMinus)
{
if (Points - PointsToMinus < 0)
{ // }
else { Points -= PointsToMinus; }
}
I have attached that to the item Cam and it has no compiler error but when I use this…
public GameObject Cam;
public GameObject Buytext;
public GameObject Barrier;
public GameObject SorryText;
// Use this for initialization
void Start ()
{
Buytext.SetActive(false);
}
void OnTriggerEnter()
{
Buytext.SetActive(true);
}
void OnTriggerStay()
{
if (Input.GetKeyDown(KeyCode.E))
{
Barrier.SetActive(false);
Buytext.SetActive(false);
}
}
void OnTriggerExit()
{
Buytext.SetActive(false);
}
Earlier I had tried to call upon my points variable in the if statement under OnTriggerStay like this…
if (Input.GetKeyDown(KeyCode.E & Cam.GetComponent<PlayerPoints>.Points = 500) {
Barrier.SetActive(false);
Buytext.SetActive(false);
}
but it gave me the error :
CS0119 ‘GameObject.GetComponent()’ is a method, which is not valid in the given context
What am I doing wrong or am overlooking???