How do i get a real random number? Which is the volume DB property of audiostream and how do i know it's path?

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

Hi again!

Random number
I’ve been testing with random numbers, i’m using randi()%4+1 to get a number between 1 to 4,but when i run the game i always get the number 3 first,and this is not what i want to get as “random number”.

I need to get a random number between e.g. 1-4,without having that pattern.I read about randomize() but i don’t got it to work,i didn’t find an example of how to use it, i just know it exist,if someone could help me i would appreciate you a lot.
Answered by: GameVisitor

AudioStreamPlayer property
Also i’ve tried to tween the volume from -25 db to 0 but it is not working,i’m pretty sure that the problem is the property path of the volume property,here is my line of code:$Tween.interpolate_property(self,"volume_db",-25,0,7,Tween.TRANS_LINEAR,Tween.EASE_IN)
I’ve also tested AudioStreamPlayer/volume_db and nothing…

Thanks,and have a great day.

Please create individual threads for each question you may have, it’s less confusing and easier to search this way :slight_smile:

You can leave this one as-is, just remember that for the next time you ask a question.

Calinou | 2018-08-25 10:03

:bust_in_silhouette: Reply From: GameVisitor

Concerning the Random number issue, as you said, you need to call randomize() before any call to randi().
the best place to do so is usually in the _ready() method such as:

func _ready():
	# Called when the node is added to the scene for the first time.
    print( randi()%4+1)
    print( randi()%4+1)
    print( randi()%4+1)

It should work after this (use print to see the values)

Finally! Thanks ^^!

MaximoTG98 | 2018-08-25 11:02