Animation names as a number

0 favourites
  • 5 posts
From the Asset Store
3 pixel charaters with over 8 animations each + animations with a gun
  • In C2 I can name my animations anything as long as it has an alpha numeric number in it. Problem is, I want to name my animations "1", "2", "3", etc. so something like this is possible.

    set animation to variable playerNumber

    Variable playerNumber needs to be type "number" because mathematical operations are performed on it. Anyway to get around this so I dont' have to keep doing "if playerNumber = [X], set set animation to "player[X]Animation" over and over?

  • Ahh, I just realized from my limited programming experience that the animation name is a string and the number is something akin to a float so they can't be compared, and not being able to put pure numbers as animation names was likely designed to prevent confusion.

    I'll leave this thread up so it's searchable in case something else has the same question

  • Name your animations "Animation1", "Animation2", "Animation3", etc.

    Then use :

    set animation to : "Animation" & str(playerNumber)

  • Ahh don't know why I didn't think of that. Thanks Albatr.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Name your animations "Animation1", "Animation2", "Animation3", etc.

    Then use :

    set animation to : "Animation" & str(playerNumber)

    Ahh don't know why I didn't think of that. Thanks Albatr.

    set animation to: "Animation" & randomNumber;

    You don't need the str() there. So, you can make math to achieve what you need, like:

    set animation to: "Animation" & randomNumber*randomNumber/randomNumber+randomNumber;

    I tested this way and is working fine.

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