0 Favourites

[Suggestion] Object.AnimationCount

  • 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!

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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 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.

  • > 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 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.

    But yeah, I don't know why it isn't implemented by default in c2.

  • >

    > > 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.

    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.

    But yeah, I don't know why it isn't implemented by default in c2.

    Awesome plugin, thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)