Best way to calculate the age of something??
Im creating a nature simulation game with heavy RTS elements. I have a lot of animals and plants that the player can place in their environment and they all have a lot of things that I need to calculate (Age, Fruit production, gestation lengths etc.)
My current method is using an event bound to a looping timer. So every second (Time Unit) the event fires and adds +1 to lets say the age.
Ive then taken that Time unit and multiplied it by a float called "Game Speed" Which seemed to be working fine or so I thought. When I used a dispatcher to set the game speed variable in order to increase speed and make things move along faster. It appears to be skipping the +1 to the age in random cases... I can not for the life of me figure out what to do about it.
My best example is I have a patch of grass in game. It has a component which uses the above method only it decreases a float variable "Lifetime" by 1. Then when Lifetime reaches <=0 the grass patch dies. But it doesn't... It carries on long past when it should.
Is there any better way of doing this? Other than to use the event tick.
asked Mar 11 '19 at 08:54 PM in Blueprint Scripting
Have you tried using the increment node instead perhaps? Is your time in integers? If so, increment works wonders.
answered Mar 11 '19 at 09:05 PM
Probably a solid way to do it would be to have a time manager (ie, your game mode) and each actor to just log their time of creation. This way there's only 1 object keeping track of time, and all other just read from it.
Then you can check as frequently as needed to to see how old it is:
Then all the actors have to do is to evaluate their ages to see what it is they should be doing.
answered Mar 11 '19 at 10:28 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here