I’m trying to access a variable in a script attached to the “other” object in this trigger event but I cant figure out whats going wrong unity says “score does not exist in the current context.”
here are both scripts the one with the error;
using UnityEngine;
using System.Collections;
public class PickUp : MonoBehaviour {
void OnTriggerEnter (Collider other)
{
other.GetComponent<ScoreAndPickUps>(score++);
Destroy (gameObject);
}
}
and the one its trying to access;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ScoreAndPickUps : MonoBehaviour {
public int score;
public int powerUp;
public Text points;
void Start ()
{
score = 0;
Setpoints ();
}
void Setpoints ()
{
points.text = "Points: " + score.ToString ();
}
}