Hello all, I’ve been taking a stab at this with my primitive knowledge of code for a bit now and come to you at a loss.
What I am trying to accomplish is to have a timer variable (the time the particular session has been in play) and add that to the score and use it as a determinant for other game factors (an increasing difficulty curve).
Right now I have this timer variable calculated in my Update() method using a StartTime variable in my Start() method.
public void Update()
{
…
timer = Mathf.RoundToInt(Time.time - StartTime);
}
This timer is then added to the score via a separate AddScore method
public void AddScore(int newScoreValue)
{
score += (newScoreValue+timer);
UpdateScore();
}
Later on there is an UpdateScore method that later records the score to the screen. And this seems to work, for the most part. My issue is that I can’t seem to get the code to update in real time. Meaning, I want the score to tick up every second by an increment of one if that makes sense. While not ultimately important to my final goal, it is a little jarring for the time update to only happen whenever a different trigger occurs.
Thank you for any help. Pretty new to coding in general and am using Unity (and game making) to play a bit of in my skills. If it helps any, I’m trying to expand upon the tutorial for Space Shooter. My logic was to use the tutorials as a base and experiment further.
Quick Edit: If there is some answer to this type of situation already, feel free to direct me there. I couldn’t find anything concerning this in particular but I’m sure I just missed it.