Blinking

  • #10, by ivan-parketovSunday, 10. January, 21:18 2 weeks ago
    Hello. I used the blinking tutorial, but the result was not random. I thought that the character will blink once out of three, but he blinks or does not blink constantly until the animation changes. I tried to make the function math.random() recalculate the value every time the animtion loop starts, but it didn't work. What am I doing wrong?

    1. if ActiveAnimations["animation_name"].AnimationCurrentSpriteIndex == 1 then
    2. blink = math.random(20)
    3.   if blink < 13 then
    4.    ActiveAnimations["animation_name"].AnimationLastFrame = 11
    5.   else
    6.    ActiveAnimations["animation_name"].AnimationLastFrame = 12
    7.   end
    8. end

    Newbie

    9 Posts


  • #11, by afrlmeSunday, 10. January, 22:10 2 weeks ago
    Did you replace animation_name with the actual name of the animation?

    You also shouldn't need the first if query. Also you need to make sure that you specify the correct frame values for AnimationLastFrame.

    As for math.random() it's not necessarily going to blink one out of 3, it will return a random number between 1 & 20 based on your example, so it's a 7 out of 20 chance it will play the blink animation frames.

    Imperator

    6913 Posts

  • #12, by ivan-parketovSunday, 10. January, 22:40 2 weeks ago
    Yes, I changed it to general for the example.
    The number of frames is 12. The first 11 is breathing, 12 is blinking.
    7 out of 20 is about one in three blinking possibilities. But the problem is that there is no random. The character either blinks or not, until a random animation interrupts the standing.
    More details about the last. When I start the scene, the character stands and does not blink at all. If you wait for a random animation or walk around, then the character starts blinking constantly and does not stop even after subsequent interactions.

    Newbie

    9 Posts

  • #13, by afrlmeSunday, 10. January, 23:05 2 weeks ago
    Can you share some screenshots of how you have set it up please? I can't see any reason for it to be behaving like that.

    Imperator

    6913 Posts

  • #14, by ivan-parketovSunday, 10. January, 23:24 2 weeks ago
    Here you are, please

    Newbie

    9 Posts

  • #15, by afrlmeMonday, 11. January, 00:17 2 weeks ago
    I meant screenshots of how you set up the character blink animation & action block you have written the script into.

    Quick note: you don't need the first line of code.

    P.S: sorry for taking a while to get back. I'm not as active on the forum as I used to be. Most of us are on Discord as it's just more convenient for back & forth conversations & discussions.

    Imperator

    6913 Posts

  • #16, by ivan-parketovMonday, 11. January, 00:53 2 weeks ago
    Oh, I'm so unobservant. I found an error, it turns out I put the script in the wrong place.
    Thank you for your help.

    Newbie

    9 Posts

Write post