Topic was automatically imported from the old Question2Answer platform.
Asked By
Coke Dev Unity
Hi! I’m new to Godot and GDScript and I’m making my own Minecraft rip-off for fun! I want to do the splash text thing from the game but I need the randomiser method but I don’t know how to declare it, Here’s my code
extends Label
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var splashvar = 1
# Called when the node enters the scene tree for the first time.
func _ready():
randomise (splashvar)
set_text("COOL!!!")
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
Please help
P.S I will do an If statement for the list of text
There is a function is called randomize() but it takes no arguments:
That function is used to initialize (seed) the random number generator.
I want to randomize the “splashvar”
Oh and it says randomise() in the built in docs
Coke Dev Unity | 2021-06-05 17:22
Where in the docs, because it’s always been spelled this way:
To assign a random value to a variable, you need to generate a random number. You can do that with randi() if you need an integer, or rand_range() if you need a float.