Having issues with Walking/Idle Animation when Mouse Button Held (Scripting)

Started by jjbob1234, Tue 27/04/2021 21:37:21

Previous topic - Next topic

jjbob1234

Hello all!  :grin:

Let me describe my situation;

I'm trying to set up my views to be more fluid, I Noticed that when the character switched from walking to idle there was a few frames of delay, to fix that I implemented:
Code: ags

void handleAni() {
        
    if ( !player.Moving && !player.Speaking && player.View != VT_IDLE && player.View != VT_BLINK ) {
        SetTimer(tBlink, 160);//Related to next if statement : tBlink always = 1 but i don't think this matters just explaining incase its necessary 
        player.LockView(VT_IDLE);
        player.Animate(player.Loop, 0, eRepeat, eNoBlock);
    }//This is to fix the delay between switching Views

    if(IsTimerExpired(tBlink) && !player.Moving && !player.Speaking){
      player.LockView(VT_BLINK);
      player.Animate(player.Loop, 0, eOnce, eBlock);
      player.LockView(VT_IDLE);
      player.Animate(player.Loop, 0, eRepeat, eNoBlock);
      SetTimer(tBlink, 160);
      
    }//This I implemented to control a Blinking animation for the player

    if(Mouse.IsButtonDown(eMouseLeft) && !player.Moving) //Left over from trying to fix Animation issue...
    //i haven't found anything to do with this that works yet but it felt like the correct if statement for my problem...


And I run this void through repeatedly_execute() in the Global Script.

(I also have player.UnlockView(eKeepMoving); under on_mouse_click() on the global script)

Now that I fixed the delay, I noticed if I hold the mouse button down while the player isn't moving the animations just stop, i'd like to fix this so the player animates when not moving even if the mouse button is held, I don't really mind the choppy broken animation when moving with the mouse held(Bonus points for fixing that but not necessary)
when the player isn't moving I want the idle animation to overwrite the normal view and animate always.
Any advice would be greatly appreciated.  :grin:

(edit: Sorry if this should be in advanced help, I'm not sure since I am a beginner to this engine for the most part, if this is too complex for Beginner Questions please move.)


SMF spam blocked by CleanTalk