- Home /
The question is answered, right answer was accepted
Fast Forward Time like in the Sims 3 using DateTime
Hello party people!
I currently have this in my update which tells the time perfectly but when I try to add an hour when my character does an 'activity' it automatically updates to the current time instead of the changed time because it is in update. Any thoughts would be greatly appreciated!!
void Update ()
{
currentTime = DateTime.Now;
int gameTimeHour = currentTime.Hour;
int gameTimeMinutes = currentTime.Minute;
text.text = gameTimeHour + ":" + gameTimeMinutes;//currentTime.ToString();
}
Answer by KelseySHock · Jun 23, 2018 at 06:17 PM
Guys I half solved it! I can get an hour to be added but when I go back to my object again another hour isn't added (ie. It only adds an hour the first time I collide with the 'activity' object)
Here's my updated update() code:
void Update ()
{
currentTime = DateTime.Now;
int gameTimeHour = currentTime.Hour;
int gameTimeMinutes = currentTime.Minute;
int gameTimeSeconds = currentTime.Second;
if (skills.gettingASkill == true)
{
gameTimeHour += 1;
}
text.text = gameTimeHour + ":" + gameTimeMinutes + ":" + gameTimeSeconds;
}
And this is what my collider code looks like for my player:
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Skill")
{
Debug.Log("EARNING A SKILL");
skill += 1;
gettingASkill = true;
}
}
Follow this Question
Related Questions
How slow motion everything except animation 1 Answer
How to make notification appear at certain time without having to press button again? 2 Answers
Check How Many Minutes Have Passed 1 Answer
How to Work Out Time Passed in Seconds (Using System.DateTime.Now)? 1 Answer
I have overrided a built-in script accidentally and not sure how to fix 2 Answers