You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func _ready():
var mob_types = $AnimatedSprite2D.sprite_frames.get_animation_names()
$AnimatedSprite2D.play(mob_types[randi() % mob_types.size()])
Thoughts on this?
func _ready():
var mob_types = $AnimatedSprite2D.sprite_frames.get_animation_names()
$AnimatedSprite2D.play(Array(mob_types).pick_random())
The pick_random() method is relatively straightforward to understand, and discussing the Array data type and its methods can be quite valuable for learning purposes.
Your Godot version:
4.2.2
Issue description:
Currently, the tutorial shares this snippet:
Thoughts on this?
The
pick_random()
method is relatively straightforward to understand, and discussing the Array data type and its methods can be quite valuable for learning purposes.Via https://docs.godotengine.org/en/4.0/classes/class_array.html#class-array-method-pick-random
URL to the documentation page (if already existing):
https://docs.godotengine.org/en/stable/getting_started/first_2d_game/04.creating_the_enemy.html
The text was updated successfully, but these errors were encountered: