- Home /
Need help with creating a time-based score system with multiple objects
Hi everyone, I'm new to Unity and working on my first game right now. The objective of the game is to collect as many objects as you can and hold on to them for as long as possible without dropping them. When I looked online, all I found was ways to make a timed score that is unaffected by anything except for the time scale of the game. I want to create a score system where points are added to the score for every second that one of these objects is being held, so if you had 10, you would be generating 10 points every second, so on and so forth. Can this be done easily, and what are some tips on how I might accomplish this? Thanks!
Answer by HarshadK · Nov 29, 2017 at 02:47 PM
When I looked online, all I found was ways to make a timed score that is unaffected by anything except for the time scale of the game.
You can use any of these scripts and where the time is added just multiply the time that is added with number of items. Say for example:
score += timeToAdd * noOfItems;
Woah, will that really work? Thanks a lot. I'll look into this.
Answer by Multirezonator · Nov 29, 2017 at 04:44 PM
To ignore ingame time scale use Time.unscaledDeltaTime and Time.realtimeSinceStartup for Update() function and yeild return new WaitForSecondsRealtime(1f) in coroutines.