0 votes

I've made a simple game that has a backend structure backing it up. As a finale to my game if the user manages to win I want them to chose between 3 things all having a random server response behind them and givin the user a reward. How can I approach this?
How can I make Godot get the server response and either make a label or show a existing label I've made previously depending on the response? Along side this I want to show a different image for each of the rewards which also corresponds to the response I.e. I have a lawnmower, mixer and AC unit as my three obtainable rewards. So if my backend rolls a AC unit I want the user to see. "Congrats u got an AC my dude" and under it an image of the said AC unit.

in Engine by (27 points)

1 Answer

0 votes

So there are a number of ways to do this. You could have the server do simple RNG on the the 3 different values whenever the client sends it what choice(position) they chose. I will link the built-in RNG for the Godot engine below. This should be simple enough to figure out how to set it up if you want to use this route. If you have to create your own, because of how your server is setup, that is on you.

RandomNumberGenerator -- Godot Stable

You can then send back the data however you want, a simple way is to send a string of the path name of the image you have in project already. So you can load that into a Type:TextureRect that you set within the scene you want. If you are preloading textures(this is not a simple you would think) you can just pass the object in. If not you need to load the image then pass it in.

var currentimage:Resource = load(stringpathfromserver)
TextureRectNode.set_texture(currentimage)

Hope this helps.

by (58 points)
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.