Hi i am making an fps game . I added a coin prefab and want that when player collides with it it updates the text from (like 1- 2 then 2-3) and so on. I just want to have a working script which will allow me to pick coin and add 1 to score. I tried OnTriggerEnter but it only destroyed the coin after triggering it and i want to update the score by 1 too but my score(text) is not updating. i tried various things like these but nothing worked. It just destroys my voin after triggering but never updates the score
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
public Text text;
public int Score = 0;
void Update()
{
text.text = Score.ToString();
}
OnTriggerEnter(collider other)
{
Score++;
destroy(gameObject);
}
It is quiet difficult and there are no tutorials for it on youtube . I am new to unity . i am using unity for 1 month now that means i am very new to coding and unity. If anybody knows how to make this work please help me please. Please give me a working script and tell me how it works pleaseee.
Take a deep breath, work through at least two of the tutorials. This is monkey-simple basic stuff, but the code is perhaps only 25% of the problem: the scene(s) and prefab(s) have to be set up just so.
When you have a SPECIFIC question, here is how to report your problem productively in the Unity3D forums: