Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Crimson Lab on Sat 27/07/2024 21:26:12

Title: Change between walking and running view when double clicking.
Post by: Crimson Lab on Sat 27/07/2024 21:26:12
Hello!

There's an issue in my game project that I cannot seem to figure out.
Basically, I want my character to change views depending on whether he is walking or running. I have searched for a solution but cannot quite make it work.

Here is how I want the movement to function:


I have tried to change the view depending on mouse clicks, but maybe there is a way to do it depending on character speed? For reference- I am using tumbleweed preset so I have the DoubleClick and TwoClickHandler scripts.

Here is the movement code that is in TwoClickHandler script under "do_room_action(MouseButton button)"function:
Code (ags) Select
      if (button != eMouseLeft) return;
      int speed = 5;
      player.StopMoving();
      if (DoubleClick.Event[eMouseLeft]) speed = 15;
      player.StopMoving();
      player.SetWalkSpeed(speed, speed);
      Room.ProcessClick(mouse.x, mouse.y, eModeWalkto);

Any help would be greatly appreciated! Also, I am not a native English speaker so I apologize for grammar issues.  :)
Title: Re: Change between walking and running view when double clicking.
Post by: Khris on Sun 28/07/2024 12:30:51
Just in general, please always describe what the actual result is, as opposed to what you expected.

From your code it looks like you simply forgot to call player.ChangeView().

  // after player.StopMoving();
  if (speed == 5) player.ChangeView(PLAYER_WALK);
  else player.ChangeView(PLAYER_RUN);
Title: Re: Change between walking and running view when double clicking.
Post by: Crimson Lab on Sun 28/07/2024 12:50:44
Quote from: Khris on Sun 28/07/2024 12:30:51Just in general, please always describe what the actual result is, as opposed to what you expected.

From your code it looks like you simply forgot to call player.ChangeView().


I apologize! It's my first time posting.

And thankyou! It works perfectly.