How do I random player selecting ???

  • gi,

    i have for example same player character with 3 color

    i want that every start of new player , the player change color randomly !!!! how i do it ?

    thanks

  • Like with most "How do I" questions, there are a lot of ways to accomplish this. However, here is a way that will absolutely minimize the number of actions you need.

    1 - Create a variable (it should be an instance variable on the character but my example has it global so you can see it in the event sheet)

    2 - Create your event where the change should happen

    3 - In the action, set the global variable using the following expression: round(random(2))

    random(2) chooses a random decimal number between 0 and 2, not including 2 and round() rounds it to an integer. Because you are rounding, you will get the number 2 even though random doesn't include 2. This is important in a later step.

    4 - Set all your animations to be the same name with a 0, 1 or 2 at the end (ie: idle0, idle1, idle2) and make sure the number corresponds to the color (all blue animations use 0 etc...)

    5 - when choosing the animation set it to the base name & number (animation = "idle" & animationNumber). The & sign combines strings so if animationNumber = 1 it turns this example into "idle1".

    That's all. See the attached example for a simple use.

    I hope that helps you and good luck with your project.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thanks a lot

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