Random Character Creation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rikyrd

I’m pretty new to Godot and programming in general, so I was looking some tutorials to start with, but I couldn’t find any about generating random characters with names and different sprites.

What’s the best way to create random characters with random names and stats?

Thanks in advance.

Do you know how to code? This is less of a Godot question than a basic programming one. Your best bet may be to start with a beginner Python tutorial to cover the essentials of writing code and manipulating data.

kidscancode | 2018-07-03 21:26

I’m more of an artist myself, I will take a look at tutorials from now on, thank you.

rikyrd | 2018-07-03 21:54

:bust_in_silhouette: Reply From: Andrea

creating a character is quite a big task, i´ll stick on how to create random variables.
there are several random function, in my opinion the easier to work with is rand_range(x,y) which will generate a random float number between x and y.
another good one is randi() %X which will generate a positive integer number between 0 and X-1 (if X is negative it will transform it to positive).

Remember that by default the random seeds used by godot are always the same, meaning that if you launch this code:

func _ready():

it will always print the same number. If you want to randomize the seeds too, you have to use randomize().

func _ready():

will produce a different number every time.

Generating random strings could be done by converting number into char, i dont know if there is a built-in function to do it.