vWest
Trying to get a game object to disappear and re-appear when a certain number of items are collected.
it isnt working, i have tried a different solution by creating a new script but when i try and drag it onto the spaceship i get this error message 'Can't add script component 'ShowSpaceship' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.'
34 replies
Trying to get a game object to disappear and re-appear when a certain number of items are collected.
thank you for that, i understand some of that, but when i say im new to c# i have so very little knowledge of it at all that I dont know how to even pass something by referance
34 replies
Trying to get a game object to disappear and re-appear when a certain number of items are collected.
public class Finish : MonoBehaviour
{
public void Update()
{
if (itemcollection.item == 3)
{
gameObject.SetActive(true);
}
else
{
gameObject.SetActive(false);
}
}
34 replies
Trying to get a game object to disappear and re-appear when a certain number of items are collected.
public class itemcollection : MonoBehaviour
{
static public int item = 0;
[SerializeField] private Text itemText;
public void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.CompareTag("item"))
{
Destroy(collision.gameObject);
item = item + 1;
itemText.text = "Fuel: " + item;
}
}
}
34 replies