Godot 3 - GDScript Tutorial - Arrays

preview_player
Показать описание
The sooner you learn about arrays, the sooner you'll find all sorts of ways to use them.

Download for this project available at:

Original sprites by "ArMM1998"
Рекомендации по теме
Комментарии
Автор

please keep this up it really helps people to learn about Godot

j.
Автор

This was super helpful! I was trying to figure out a way to have a node randomly change its animation via a random number plugged into animation.play( ), having named the animations numerically, but I couldn't figure out how to plug it into the string. Using the knowledge here, all I had to do was list the animations in an array and then plug that array variable into to play function with my rand_range number in the brackets to randomly call from the array:


var rnd = null
var punches = ["jab", "cross", "left hook", "right hook", "left uppercut", "right uppercut", "overhand right"]
func _ready() -> void:
countdown()

func countdown():
rnd = floor(rand_range(1, 7))
yield(get_tree().create_timer(3), "timeout")
punch()

func punch():

yield($AnimationPlayer, "animation_finished")
countdown()

pattyorigami
Автор

Thank you for these tutorials :D, but can you talk about the image matrix?

pokerkyu
Автор

Is there any easy way to use 2d+ arrays in godot?

Aqrelon
Автор

So what's the best use for Arrays and Dictionary ? Dictionary is good for inventory, what about arrays? For a list of things ?

monochroma
Автор

I have a question. Is it possible to make a script that adds elements to an array. In your tutorial you used the array to find how many "fruits" we had in a "bag".
How would we make a script that sets individual fruits to be in that bag, then use the array to find out what fruits they are? Thanks!

comfyzenny
welcome to shbcf.ru