0 votes

I'm not really sure how to better put the question in one sentence.

I'm making a simple test-game for my company that is supposed to give the player a reward if he/she manages to compleate it. Currently I have a primitive random number method that gives the player the reward depending on what number they recieve and send a HTTPRequest to the backend which stores what reward a user got (This is all done with multiple databases thoughout my Webapp).

I was wondering what would be the best way to go about making a function that would not only give a player a reward (as in are there better ways to go about this outside a random number generator), but also once a player gets the reward to signal the either backend or a structure within the game that the reward size gets decreased as less and less of the specific reward become available and ultimatly once the reward is depleted to make the user get another reward which is currenly available.

I was assuming a global variable would be something that I can use however as I'm new to the engine I don't know is there a way for the variable not to reset between users i.e. if I make a counter-- how can I make this counter be active over all the users that have/are playing instead of it being set a number and setting its self back to that number each time the game is booted up again.

Godot version Godot 3.3.2
in Engine by (27 points)
edited by

Any ideas even without the solution would be appreciated.
Thank you in advance!

If the reward pool is shared between all players in a game and it is online multiplayer, I believe that the best approach is to store the variable in the backend and let it select reward and decrease the count.

In local multiplayer you could use a variable (or maybe more than one) in the game scene, but since you are going to use a server anyway I would ge with the logic on backend.

You could use very simple values to represent rewards, just associate an int to type of reward. I would also create an identifier for each game (match, it depends on the nature of the game) to allow multiple matches to run at the same time.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.