UnlockView Problem with character facing a direction

Started by Kumpel, Sun 24/01/2016 02:42:57

Previous topic - Next topic

Kumpel

Inside of a Use-Inv-on-hotspot function I want the player to put something in a panel, talk with a guard and take it back. All this happenes in the up-right direction.

Code: ags
function hFach_UseInv()
{
  if (player.ActiveInventory == iBAMF1Brief)
  {
   player.Walk(137, 185, eBlock, eWalkableAreas);
   player.FaceLocation(cPfoe.x+2, cPfoe.y-2, eBlock);
   player.LockView(3);
   player.Animate(0, 7, eOnce, eNoBlock);
   Wait(30);
   player.UnlockView();
   //Display("%d",player.Loop);
   player.FaceLocation(cPfoe.x+2, cPfoe.y-2, eBlock);
   player.Say("Hallo. ...");    
   cPfoe.Say("Okay. ...");    
   BAMF_schr = true;
   player.LockView(3);
   player.Animate(0, 7, eOnce, eNoBlock);
   Wait(30);
   player.UnlockView();
   //Display("%d",player.Loop); // 
   player.FaceLocation(cPfoe.x+2, cPfoe.y-2, eBlock);
   player.Say("Danke.");
   dPfoe1.SetOptionState(7, eOptionOff);
   player.UnlockView();
  }
}


But always after the animation, when the required UnlockView() is on, the character jumps to loop 0 of the NormalView which turns the character for a splitsecond to the down-direction and immediately back to the up-right-direction. How can I fix this?

I had the impression that AGS stores which loop was active before some forced change of direction happened and goes back to this direction when the view is unlocked. Am I wrong and AGS always uses loop 0 after UnlockView()?

Or is my animation in loop 0  the problem which makes AGS think, the normalview loop has to be the same?

Khris

Not sure it makes a difference, but you could try making the animation blocking and removing the Wait() command.
If that doesn't help, move the frames from View 3's loop 0 to the one the player is using before the animation starts.

Kumpel

Yep! That second idea worked (first didn't)!

I had to duplicate the view (I had to put it in loop 5: north-east direction) because the original view with my strange, naturally grown loop structure is far to often used in my game now, but I can live with that, Thanks!

Maybe you guys wanna consider changing the UnlockView() to use the actual last loop that was used in normal view and not just transfer the loop number of the last animation to the normal view? :) Or let the user decide it via some properties? Just a suggestion.

SMF spam blocked by CleanTalk