[SOLVED] Faster view switch and faster animation speed

Started by tor.brandt, Wed 26/10/2016 22:55:42

Previous topic - Next topic

tor.brandt

In my game I want a character to become shaky after a certain event.
For this purpose I've used
Code: ags
player.AnimationSpeed = 0;
player.SetIdleView(7, 0);


where view 7 consists of two frames, such that the character 'jumps' up and down continuously whenever he is not walking.

However, I have two problems here:
1. Even with delay 0 in the idle view, there is still a bit of a delay after the character stops walking before he switches to the idle view. Is it possible to make him switch to the idle view faster in any way?
2. Even with animation speed 0, the shaking is not fast enough. Is is possible to make the character animate faster in any way?

On closer inspection, it seems that only the normal (i.e. walking) view is affected by AnimationSpeed. If that's correct, how do I change the animation speed of other views?

Danvzare

Use player.SetIdleView(7, -1); to get rid of that slight delay.
I'm not sure about the animation speed though. I'll have to look that up.

Snarky

#2
There doesn't seem to be a way to change the speed of the idle animation as a whole (it is apparently fixed to 5 cycles/frames, i.e. 8 fps if the game is running at the default 40 cycles/second), but you can adjust the delay of individual frames in the view editor. By setting a negative number for the delay in the frame's properties, it will display for a shorter time. Setting the delay of each frame to -4 or -5 (I'm not sure which) should run the animation at the fastest possible speed.

Another approach would be to not use the IdleView, but instead put some code in repeatedly_execute() to lock the view and play an animation whenever the character is not moving. Character.Animate() allows you to set the animation speed.

Arlann

QuoteUse player.SetIdleView(7, -1); to get rid of that slight delay
I think it will start walking animated view instead of the idle view...
I also noticed this little delay problem on my playable character, but not on the NPCs. (I don't understand why...)
So I made like this:
Code: ags
function repeatedly_execute_always() 
{
  
  if ( player.Moving == false && player.View == VWALK ) {
    player.LockView(VIDLE);
    player.Animate(player.Loop, 0, eRepeat, eNoBlock);
  }

}

I also added player.UnlockView(); in my on_mouse_click function before calling the walk command.

tor.brandt

#4
Thanks for the replies!

@Danvzare:
I actually tried using a negative number for the delay int, but yeah, that just weirdly made the character switch to the animated (i.e. walking) normal view like Arlann says.

@Snarky:
Thanks for the individual frame tip, that works perfectly!
And yeah, it might be a better solution to make a repeatedly_execute() Character.Animate() function instead, thanks.

@Arlann:
Thanks for the code bit.
I actually tried using that right now, and strangely there is still a delay from the character stops moving before he starts animating, sometimes more than a second.
I don't understand why...

edit: No, now I found out it was because I had forgotten an old code bit that counteracted your bit. Now it works perfectly :smiley:

tor.brandt

#5
@ Arlann:

I just noticed, however, that when the character hos spoken (i.e. have been animated with his speech view), he does not return to the idle view again.
I have to make him walk before he switches back again.
Have you experienced something like that?

edit: Whoops, sorry, I was a little too fast there.
It was just because I had only put the UnlockView() command as a function of left mouse buttion click, and therefore it did not unlock when clicking right button (performing look at).

Arlann

#6
I did not have talking view on this project...
May be doing something like this:
Code: ags
function repeatedly_execute() 
{
      
    if ( player.Moving == false && (player.View == VWALK || player.View == VTALK) ) {
        player.LockView(VIDLE);
        player.Animate(player.Loop, 0, eRepeat, eNoBlock);
    }
     
}


Edit : Or you could try this :
Code: ags
function repeatedly_execute() 
{
      
    if ( !player.Moving && !player.Animating && !player.Speaking && player.View != VIDLE ) {
        player.LockView(VIDLE);
        player.Animate(player.Loop, 0, eRepeat, eNoBlock);
    }
     
}

tor.brandt

@Arlann:

I see you replied almost at the same time as I made my last edit, so you probably didn't see that, but thanks.

I actually tried something similar to your suggestions, but as it turned out, it was simply because I had forgotten to assign the UnlockView() command to both mouse buttons.
Anyway, your suggestions really helped me out :smiley:

SMF spam blocked by CleanTalk