Location Based AR Coin Collect Game Problem!
hi everyone i am a beginner
i am making a location based AR coin collect game. I built a basic scene with game objects and scripts without AR components. It worked perfectly. I was collecting coins and scoretext was increasing very well. Then i installed AR components. I made prefab gameobject and scoremanager. After this when start the game i could collect the coins but score text did not increase. Objects dissappear but does not affect the score text. How can i figure it out the problem. Please help me. Sorry for english.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Balloon : MonoBehaviour
{
[SerializeField] private Vector3 _rotation;
[SerializeField] private float _speed;
public int scoreToGive = 1;
public int clicksToPop = 5;
public float scaleIncreasePerClick = 0.1f;
public ScoreManager scoreManager;
void OnMouseDown ()
{
clicksToPop -= 1;
transform.localScale += Vector3.one * scaleIncreasePerClick;
if(clicksToPop == 0)
{
scoreManager.IncreaseScore(scoreToGive);
Destroy(gameObject);
}
}
void Update()
{
transform.Rotate(_rotation * _speed * Time.deltaTime);
}
}
using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro;
public class ScoreManager : MonoBehaviour { public int score; public TextMeshProUGUI scoreText;
private void Start()
{
UpdateScoreText();
}
public void IncreaseScore (int amount)
{
score += amount;
UpdateScoreText();
}
void UpdateScoreText ()
{
scoreText.text = "Score: " + score;
}
}
Your answer
Follow this Question
Related Questions
Code check. Is my Highscore saving code OK? 3 Answers
Keeping points tallied 1 Answer
Saving highscore for each levels 0 Answers
When should I use static fields/methods? 2 Answers
How do I make a Score and Highscore thingie in game over screen 2 Answers