4/14/2023 0 Comments Subnautica game notesHoursToMinutes() functionįollowing up, we’ll have to create a function that will help to convert the number of hours to minutes. In the actual game, a day in-game translates to 20 minutes in real-time (i.e 20h to a day in-game), so let’s go ahead and model after that. This function will also convert minutes to hours, and hours to the number of days.įor this game, we’ll change the rate of time a little bit such that one second in real-time would translate into an hour in-game. Every time it’s called, it should increment each minute by one, and ensure that it doesn’t exceed 60. The next step is to create a function that will increase the time. Public GameTimeStamp(GameTimeStamp timeStamp) ![]() create a new timestamp from an existing one Public GameTimeStamp(int day, int hour, int minute) Public class GameTimeStamp : MonoBehaviour ![]() GameTimeStamp.cs using System.Collections One to set up the class, and the other that helps create a new timestamp with reference to an existing one. We’ll need to create two constructors for GameTimeStamp. ![]() Creating the class constructor for GameTimeStamp Then, we’ll create the integer variables that will store the day, hours and minutes of the game. We’ll also need to make the script serializable so that we can see it clearly in the inspector. Take note that this will not be a MonoBehaviour class, so you can remove that from your script – and because of this, we can also remove the default Start() and Update() functions. This class will store the number of minutes, hours and days that have passed in the game. Let’s start off by creating a class called GameTimeStamp. The time system that we want to create will be rather complex. Directional lights can emulate sunrise and sunset in Unity.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |