Stopping character animation?

Started by Doctor Oakroot, Wed 19/09/2007 22:21:16

Previous topic - Next topic

Doctor Oakroot

Is there a direct way to stop a repeating animation for a character? Apparently StopAnimating only works for objects.

I found that changing the view stops the animation, but I was trying to stop the animation while staying in the same view. I ended up changing the view to a different view and then immediately changing it back - that worked but seems clumsy.

Just changing the Loop caused the animation to continue in the new Loop (which was very funny to watch, but not what I was after, lol)

Khris


Doctor Oakroot

Yeah, I tried that... no effect. I'm guessing StopMoving stops Walk... but in this case the character is standing in one place but animated.

Ashen

Moving the character stops animations, so Character.Walk (non-blocking) followed by Character.StopMoving should stop the animation (and because it was a non-blocking movement, they won't actually appear to move). I'm not sure that it's any less clunky than two View changes, though.

What exactly are you trying to do? A neater way may be to make the animation run using the Character's Idle view, with a delay of 0 (as suggested in the BFAQ). Changing the delay to something longer will stop the anim when you're done with it.
I know what you're thinking ... Don't think that.

Doctor Oakroot

The character is playing a guitar until the guitar music ends (the guitar music is played once with repeating background music queued after it).

Sounds like the Walk/StopMoving or the idleview thing would also work, but nothing as direct as StopAnimating.

I need to read up on controlling the idle view.

Thanks for some good ideas.

Charity

What about putting the somewhat clunky code in its own function, like this?

Code: ags
For 2.8:
function StopCAnimating(this Character*) {
  int currentview = this.View;
  this.LockView(0);
  this.LockView(currentview);
}

For 2.72:
function StopCharacterAnimating(int chara) {
  int currentview = character[chara].View;
  character[chara].LockView(0);
  character[chara].LockView(currentview);
}


It's still the same solution, but at least you don't have to keep typing/pasting it if you're going to be using it a lot, and it will look neater in your script.  But perhaps I am a little function happy.

Ashen

#6
I'm as function happy as te next person, but I'm not sure that function is the way to go - you don't usually want to call LockView without calling UnlockView at some point (LockView != ChangeView, remember), and 0 is an invalid view, so it'll cause a crash.

On further testing, a single ChangeView will actually do the job - just change it to the character's current view, e.g. (2.72 version):
Code: ags

function StopCharAnim(Character *theChar) {
  theChar.ChangeView(theChar.View);
}


EDIT:
Having the character speak will also stop any animation from running - throw in a 'Thank you. Thank you very much.' at the end of the song and you're OK :)
I know what you're thinking ... Don't think that.

Charity

Ah!  LockView didn't look right to me either, but I got scared off from ChangeView by the disclaimer.  Good to know.

Doctor Oakroot

Ah, I never tried changing to the current view. That's a pretty good solution.

I like the Say solution too.

SMF spam blocked by CleanTalk