Suggestion? Retrieve number of frames in animation

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • One thing I do very frequently is to have a set of frames in an object and then another event to set the objects frame to one of random of those frames. This can be for all sorts of things like for example you have a bush object and you have 5 different frames in that object to make the object appear as 5 different types of bushes at random.

    However I always have to change the formula as I add or remove frames so if I have 5 frames I have set to random(5) etc. But if I add another one I have to manually change it to 6 (or have an alterable value to change).

    My question (or suggestion if it is not possible) is if it would be possible to instead just set the objects frames to random for however many frames there actually are? This would cut out a lot of busywork.

    Steam games: Please login to see this link.

  • As far as I know, there's no way to detect how many frames an animation has.

    However, you could do something like this (pseudo code):

    1. set an alt. value for the object you want to know how many frames has its animation. Give this alt. value a meaningful name, for example: maxFrames.

    2 start of frame: run once the animation for that object and

    ---> IF current frame > maxFrame then
    set the maxFrame to the current frame
    Now, when the animation has finished, you have in the Alt. Value "maxFrames" the number ( minus one ) of frames for that animation.

    Hope it makes sense to you.

    Regards,
    Sergio

    Example: bare in mind, that in order to work, this method requires that the animation is not looped.

    Please login to see this attachment.

  • Have a value like Frames_Max, and in events to get the the last frame index you would change the animation frame to something high like 999, which will clamp to the last animation frame, and in the same event set Frames_Max value to the current frame index (In case you want the count instead of last frame index you would add 1 as animation frames are 0-index based). After you set the value, you return the animation to it's og state if needed.

    Game/App developer, artist and a community contributor.
    You can support my work on: Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!