Character.Follow not animating while following

Started by AndreasBlack, Sun 25/09/2022 14:36:55

Previous topic - Next topic

AndreasBlack

I have a normal view with walkcycles set for the NPC that is supposed to follow the playable character, but he just floats around.  (laugh)
Do i need to manually start his walkframe animations somehow when following the player  ???


Slasher

#1
If the normal (walking) view of the npc has walking view loop frames and this walking view is set in the npc properties then the npc will walk automatically when following another character...as per Follow Character Command. (Character/Distance/ Eager).. The  Follow Character plays walking view..

AndreasBlack

Quote from: Slasher on Sun 25/09/2022 15:03:40If the normal (walking) view of the npc has walking view loop frames and this walking view is set in the npc properties then the npc will walk automatically when following another character...as per Follow Character Command. (Character/Distance/ Eager).. The  Follow Character plays walking view..

Thanks for replying, hmm, maybe the issue is that he is using the same view as the main character at the moment then. Will update his sprites and see!

AndreasBlack

#3

Edit: Turns out it is FOLLOW_EXACTLY that is causing the walkcycles not to work. Any idea how to use follow exactly with working walkcycles since the head should be able to spin around and have movement just like the overall body. It's a "costume".

Khris

It's using the same view? But FOLLOW_EXACTLY is used to put a 2nd sprite over or under the walkcycle sprite; if the following character uses the same view, why have them follow in the first place? It'll draw the same sprite twice, at the exact same position.

Anyway, if the following character doesn't change their frame according to the player's walkcycle you can do that in repeatedly_execute_always:
Code: ags
  cFollowing.Loop = player.Loop;
  cFollowing.Frame = player.Frame;

AndreasBlack

Well it was just for the test, i had not imported the new sprites so i just took an existing view from the same character, turns out it had nothing to do with it. It was just that i'd tried to use FOLLOWEXACTLY and that did not have any movement in it from the get go obviously. (laugh)

Ahh! Nice, Thanks as always Khris!

AndreasBlack

#6
Ran into a serious issue. Game crashes when changing to some rooms using the code. Not sure what is causing it other then that it has to do with the character's views not changing fast enough for the room change obviously, and how to avoid that i have no idea, tried adding some int to the leave_room to switch it temporarely to repeatedly execute, since that seems to work but then yeah, no movement of the ghostbody ofc!

"Character Loop: invalid loop number for this view"

Not sure if it helps but here's a hotspot for a door that get's a crash. Edit: Perhaps i should null it when clicking the open door verb? hmm.

Edit: It's really ackward considering going into a typical "thumbleweed doorlock " hotspot, the other door with same treatment pretty much? He comes out fine into another room without the crash, and the codes looks nearly identical.


Code: ags
  if (player.ActiveInventory==iBedroom_Key && !player.Walk(42, 107, eBlock, eWalkableAreas))
  
{

    aDoor_Unlocked.Play();
      player.Animate(9, 5, eOnce, eBlock);
    Unlocked_Doors++;
}


  if (Doors.AnyClickSpecial(10, oBedroom_Door.ID,  42,  107, eDirectionLeft, 1, 200, 145, eDirectionLeft, aDoor_Opened, aDoor_Closed, iBedroom_Key.ID, 0) == 0) Verbs.Unhandled();


 
  if (Verbs.UsedAction(eGA_UseInv) && player.ActiveInventory == iBedroom_Key) player.LoseInventory(iBedroom_Key);

Khris

#7
Thanks to the repeatedly_execute_always code, AGS wants to use loop 9 of the costume view to also animate the FOLLOW_EXACTLY character along with the player. However there's no loop 9 in that view.

So you need to either
a) provide a costume view that has those loops
or
b) wrap the two lines from my previous post into a conditional based on a global variable or something and turn it to false first

On an unrelated note: using just player.Animate(9, 5, eOnce, eBlock); is unsafe; you should put those loops into a separate view and lock the player to that view first as shown in the example code here: https://adventuregamestudio.github.io/ags-manual/Character.html#characteranimate

AndreasBlack

Ahhh, ofc! I had a loop for 8 which is open door to the right "frame", but for unknown reason missed to add the 9th frame "left". I see now, Thanks!

SMF spam blocked by CleanTalk