Please answer l need you, l am stuck at this topic for about 2 months, if you solve me this problem l can launch my first game, if u do not l dont know where to find answers anymore. Please l am looking forward for your responds.
========================================
This is my script for coins
public class Coin : MonoBehaviour
{
public float speed;
private void Update()
{
transform.Translate(Vector2.left * speed * Time.deltaTime);
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("Marko"))
{
CoinText.coinAmount += 1;
Destroy(gameObject);
}
}
}
And score Manager
public class ScoreManager : MonoBehaviour
{
public int score;
public Text scoreDispaly;
public const string PrefScore = "prefScore";
private void Update()
{
scoreDispaly.text = score.ToString();
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Obstacle")) {
score++;
Debug.Log(score);
}
}
}