Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to create Energy/Lives that regen in realtime on mobile devices?

I want to create one of those systems on an android device where, losing a level takes away one life point, but you have to wait, say an hour, to get another life point, and you can't play if you have no lives.

The idea I've thought of is to, when the player opens the level select, check the time difference from the last time they opened the level select, and then calculate how much time has passed and go from there, dividing the time by the length, refilling, etc.

Although this seems simple and easy, is there any other ways to do this?

EDIT: To be more clear on what it is I am trying to do, I want an energy system similar to Dots, CandyCrush, BestFiends and other similar games.

Every 15 minutes the player will regen one more energy point. There is a timer visible in the UI ticking down til their next regain. If they were to close the app for two minutes, then return, two minutes should have passed on the in game timer as well. And if they are gone for an hour, when they come back, they will have four energy points and the timer is again counting down to the next regain point.

The timer has to appear to be constantly ticking when the app is not running, so they can always open it up and see that every second that has passed in the real world as passed in the game.

Product Version: UE 4.14
more ▼

asked Feb 02 '17 at 03:05 AM in Blueprint Scripting

avatar image

328 17 27 57

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I would probably store a list of active start times for each timer and then you can find out where their appropriate end time should be by adding to start time and comparing that against the current time. If the timer still needs to run then you can update it in tick as it counts down towards the end time.

more ▼

answered Feb 02 '17 at 03:20 AM

avatar image

1k 37 12 38

avatar image Willard720 Feb 02 '17 at 07:26 AM

This makes sense, except for there being multiple timers. Is each timer for each interval of energy regain?

avatar image MonsOlympus Feb 02 '17 at 10:04 AM

Well not knowing a whole lot about how your game works I used the standard social game template in my thinking which has energy and build/craft times for various things that are happening.

What I was thinking instead of checking based on what time you open/close things then check vs the last time you gave the player energy/lives. If you gave them a life every 5 mins then it shouldnt matter if they are in the level select or not was my line of thinking that you want to award them that in realtime as you suggested.

Perhaps you can give some more details on what youre trying to achieve as an end result rather than your method of getting there.

avatar image Willard720 Feb 02 '17 at 02:07 PM

Okay, I've added more information. And, not to be rude, but your lack of punctuation also makes it hard to understand.

avatar image MonsOlympus Feb 02 '17 at 02:24 PM

Here I was thinking you dont start a sentence with and! Good luck!

avatar image Willard720 Feb 02 '17 at 03:19 PM

I'm not surprised you think that, considering you have poor grammar in the first place.

Fact of the matter is, starting sentences with conjunctions are more than just allowed and can be found used in the best pieces of writings. It adds a dynamic flow to the writing causing it to "bump" up and grab their attention. They only teach it to be wrong in school because little kids tend to misuse/overuse it.

And, if you don't believe me, feel free to look into it. Considering your level, right about here is a good place to start.

And, you might actually learn that you're supposed to put quotes around your "and" when you reference it like you did!


(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question