Blinking

  • #1, by zurikTuesday, 14. May 2019, 10:05 5 years ago
    Hey, how do I add blinking (or similar: for example looking around) animations without using Lua? I am guessing I have to input a blinking frame to Random animations folder in the Outfits menu for the NPC character? What next?  
    Thanks

    Newbie

    40 Posts


  • #2, by sebastianTuesday, 14. May 2019, 11:05 5 years ago
    thats it. These random animations gdt played from time to time randomly

    Thread Captain

    2346 Posts

  • #3, by zurikTuesday, 14. May 2019, 11:59 5 years ago
    Cool. Can I adjust how often the random animations should play? 

    Newbie

    40 Posts

  • #4, by afrlmeTuesday, 14. May 2019, 12:20 5 years ago
    Cool. Can I adjust how often the random animations should play? 

    Yes, with Lua - haha grin
    Characters["Tom"].Outfits["default"].RandomMinTime = 1000
    
    Characters["Tom"].Outfits["default"].RandomMaxTime = 3000

    Now, you need to take into account that you need to do this for every character/characters outfit that you want to change the min/max random animation time for.

    here's a tutorial I created a while back for adding dynamic blinking to characters - I think I've refined it since then, but it's still valid.

    Imperator

    7278 Posts

  • #5, by zurikWednesday, 15. May 2019, 10:00 5 years ago
    Thanks. 
    Sorry, I am not very experienced with Lua grin
    Outfits["Unnamed"], but where/how do I define which animation's RandomMixTime I am adjusting?   

    Characters["Tom"].Outfits["default"]. ----  here?-----.RandomMinTime = 1000

    Newbie

    40 Posts

  • #6, by afrlmeWednesday, 15. May 2019, 11:54 5 years ago
    Random animation min/max time is global for the outfit, you can't specify which random animation it should play, hence why it would probably be better to use the method in my tutorial that I linked, if you want something more consistent.

    Imperator

    7278 Posts

  • #7, by zurikSunday, 19. May 2019, 09:26 5 years ago
    Thanks. I managed to add a random blinking for my character with your code, but even though I adjust random value to "as often as possible", he blinks very rare.

    Is there any difference where I put the animation, when it's controlled by Lua anyways?

    Newbie

    40 Posts

  • #8, by afrlmeSunday, 19. May 2019, 11:56 5 years ago
    For me, I inserted the animation into the idle animations because the character breathes & I didn't want the blink animation interrupt that, but you are correct, it can be added as an animation under character animations, but you need to call the correct one based on direction the character is facing - that was another thing that blending my idle animations with blink animations took care of.

    Imperator

    7278 Posts

  • #9, by zurikMonday, 20. May 2019, 13:29 5 years ago
    I must say this is not very easy to understand grin But I am trying.
    So if I put the blinking in the Standing Animations with  a random timing variable, can I do it like this and write this code in the first script?

    if math.random(20) < 15 then
     ActiveAnimations["front1"].AnimationLastFrame = 1
    else
     ActiveAnimations["front1"].AnimationLastFrame = 5
    end


    Newbie

    40 Posts

  • #10, by afrlmeMonday, 20. May 2019, 18:34 5 years ago
    Hmm... if you are not planning on using more than 1 frame for idle animations then controlling the global pause value would be better. My tutorial was intended for idle animations that contain multiple animation frames. It works by querying a random number generated by math.random & then uses that query to determine if it should display the animation up to whatever the default idle animation frame total number should be, or it displays the entire animation including the blink animation.

    It won't work very well with a single frame because it's looping & querying every single frame.

    As I was saying, if you plan on using a single frame, then it would be better to change the global pause value between frames instead - taking into account that you need to edit the next frame & set the global pause between frame back to the default number it's supposed to be.

    Animations["example"].AnimationPause = math.random(60, 3000)

    so what we are doing in the code example above is setting the global pause between animation frames to a random number between 60ms & 3000ms. The smallest value should be whatever the default pause value is that you set - unless you always want a larger delay.

    Imperator

    7278 Posts

  • #11, by ivan-parketovSunday, 10. January 2021, 21:18 3 years 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