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:
- Upon clicking once, the character uses idle walking view when moving.
- Upon clicking twice, the character briefly stops and then moves faster using his running animation which is a separate view.
- When character reaches the destination and stops, he is set to his idle walking view again.
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:
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. :)
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);
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.