Description
In this video I go over different ways of getting random number but most importantly, how to use these techniques in game!
π Learn how to make JUICY games π https://www.udemy.com/course/learn-how-to-make-a-game-juicy-in-godot-4/?referralCode=1652C74B848551E05DAE
USEFUL STUFF
π Video about noise
https://www.youtube.com/watch?v=sChQCdbLdHE
π RandomNumberGenerator
https://docs.godotengine.org/en/stable/classes/class_randomnumbergenerator.html
π Random number generation tutorial
https://docs.godotengine.org/en/stable/tutorials/math/random_number_generation.html
π Random element with weighted probability
https://github.com/godotengine/godot-proposals/issues/3948
π Value vs reference
https://www.bogotobogo.com/cplusplus/valuevsreference.php
π€ SOCIALS
π° One time donation: https://ko-fi.com/mreliptik π° Support me on Patreon: https://patreon.com/MrEliptik π£ Join us on Discord: https://discord.gg/83nFRPTP6t π΄ Twitch: https://twitch.tv/mreliptik π€ Twitter: https://twitter.com/mreliptik π₯ TikTok: https://www.tiktok.com/@mreliptik πΌοΈ Instagram: https://www.instagram.com/mreliptik πAll links: https://bento.me/mreliptik
My Notes
00:00 - Intro
00:32 - TIP 1: how to get random numbers?
01:16 - TIP 2: random numbers in a range
03:51 - TIP 3: weighted distribution
func _on_WeightedBtn_pressed() -> MyObject:
var result = randf()
if result < 0.1:
return objects[0]
elif result < 0.7:
return objects[1]
else:
return objects[2]
A better solution would be to use a dictionary, but this requires a more complex algorithm.