How would I get arrayobject[X], X being a variable

How do I…

set the health behavior to be equal to item[variable] of an array (a variable with a numerical value)

What is the expected result

being able to get ‘variable’ item from an array and set that as the max Hp for the health sprite behavior.


I’m trying to have max health determined by what archetype is picked, im new to gdev, and my go to for this type of thing is setting that value to be item X of a list/array/etc, I have no idea how to get that to happen when using the drop-down menu provided in the behavior and event tabs, maybe I’m blind but I couldn’t find what I needed, any insight would be lovely and greatly appreciated. ^^

I think this video might help you! https://www.youtube.com/watch?v=irG4e2HoaEw

They have lots of tutorial videos which are great for learning the basics!

1 Like

Appreciate it, ill watch it before marking as resolved if thats fine, but truly thank you ^^ have a cracking one

3 Likes

First of all, welcome to the GDevelop community! :smile:

You should just be able to input the variable in the [ and ]. This worked for me:

Variables:

Output:

Was this what you were looking for, or am I missing something?

Happy GDeveloping!
– Snowy

1 Like