[Suggestion] Object.AnimationCount

Discussion and feedback on Construct 2

Post » Sun Oct 23, 2016 4:53 pm

Someone correct me if I'm wrong, but it doesn't seem possible to get the number of different animations an object has. This would be a helpful expression to add. Thanks!
B
71
S
24
G
11
Posts: 452
Reputation: 12,343

Post » Sun Oct 23, 2016 5:15 pm

I can't figure out any purpose of trying to figure that out but you can simply create an object numerical variable and set the value there since you, as the dev, should already know the number.
B
36
S
18
G
11
Posts: 248
Reputation: 8,694

Post » Sun Oct 23, 2016 5:38 pm

Sethmaster wrote:I can't figure out any purpose of trying to figure that out but you can simply create an object numerical variable and set the value there since you, as the dev, should already know the number.


I'm doing that right now but it's not a very good solution because if I add or remove anims I have to remember to update that number. In my case i'm using each different animation for npcs and I need to fill an array with each animation to generate them without repeats, but repeatedly. The choose() function is kinda terrible at being random.
B
71
S
24
G
11
Posts: 452
Reputation: 12,343

Post » Sun Oct 23, 2016 6:12 pm

ReflextionsDev wrote:
Sethmaster wrote:I can't figure out any purpose of trying to figure that out but you can simply create an object numerical variable and set the value there since you, as the dev, should already know the number.


I'm doing that right now but it's not a very good solution because if I add or remove anims I have to remember to update that number. In my case i'm using each different animation for npcs and I need to fill an array with each animation to generate them without repeats, but repeatedly. The choose() function is kinda terrible at being random.


Why don't you just use one array and filled it with the names of animations shared by your NPCs and just randomly picked one of them to be used?
The width of the animation array is your animations count.
It is as simple as int(random(1)*AnimationsArray.Width) which will serve to check which array x-index and animation to pull out.
If you don't want repeat, just remove each index that have been chosen after all other computation is done.
B
36
S
18
G
11
Posts: 248
Reputation: 8,694

Post » Sun Oct 23, 2016 6:54 pm

I created a behavior that does this- it also can retrieve the animation name by its index value, or retrieve the index value by the animation name.
behavior-animation-list_t122484
But yeah, I don't know why it isn't implemented by default in c2.
B
43
S
19
G
65
Posts: 1,101
Reputation: 37,939

Post » Mon Oct 24, 2016 3:48 pm

Sethmaster wrote:
ReflextionsDev wrote:
Sethmaster wrote:I can't figure out any purpose of trying to figure that out but you can simply create an object numerical variable and set the value there since you, as the dev, should already know the number.


I'm doing that right now but it's not a very good solution because if I add or remove anims I have to remember to update that number. In my case i'm using each different animation for npcs and I need to fill an array with each animation to generate them without repeats, but repeatedly. The choose() function is kinda terrible at being random.


Why don't you just use one array and filled it with the names of animations shared by your NPCs and just randomly picked one of them to be used?
The width of the animation array is your animations count.
It is as simple as int(random(1)*AnimationsArray.Width) which will serve to check which array x-index and animation to pull out.
If you don't want repeat, just remove each index that have been chosen after all other computation is done.


I'm doing that, my point is that is tedious and doesn't adapt to changes. It's not good practice to build things that break when you change something else elsewhere.

Prominent wrote:I created a behavior that does this- it also can retrieve the animation name by its index value, or retrieve the index value by the animation name.
behavior-animation-list_t122484
But yeah, I don't know why it isn't implemented by default in c2.



Awesome plugin, thanks!
B
71
S
24
G
11
Posts: 452
Reputation: 12,343


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests