I can't sync the walking animation

Posted by GlitchLatch
code:


if !ducking=true{ //if he is NOT ducking
if jumping!=true{ //if he is not jumping
if (keyboard_check(ord('W')) && place_free(x,y-1)){
sprite_index=maneken_up;
gms_instance_get(id, maneken_up); //change the sprite
if keyboard_check(vk_shift){
sprite_index=maneken_up_beg;
gms_instance_get(id, maneken_up_beg);
image_speed=0.4; //make him run
y-=7;}else{ //if you press shift
image_speed=0.2; //make the speed of the sprite
y-=2;}} //make him move down
if (keyboard_check(ord('S')) && place_free(x,y+1)){
sprite_index=maneken_down;
gms_instance_get(id, maneken_down); //change the sprite
if keyboard_check(vk_shift){
sprite_index=maneken_down_beg;
gms_instance_get(id, maneken_down_beg);
y+=7; image_speed=0.4;}else{
image_speed=0.2; //make the speed of the sprite
y+=2;}} //make him move up
if (keyboard_check(ord('A')) && place_free(x-1,y)){
sprite_index=maneken_left;
gms_instance_get(id, maneken_left);//change the sprite
if keyboard_check(vk_shift){
sprite_index=maneken_left_beg;
gms_instance_get(id, maneken_left_beg);
x-=7; image_speed=0.4;}else{
image_speed=0.2; //make the speed of the sprite
x-=2;}} //make him move left
if (keyboard_check(ord('D')) && place_free(x+1,y)){
sprite_index=maneken_right;
gms_instance_get(id, maneken_right); //change the sprite
if keyboard_check(vk_shift){
sprite_index=maneken_right_beg;
gms_instance_get(id, maneken_right_beg);
x+=7; image_speed=0.4;}else{
image_speed=0.2; //make the speed of the sprite
x+=2;}}}} //make him move right
//now where going to make him duck
//the above is: if the sprite you are walking in is that sprite, he will duck if you click d
//also if you press one of the arrow keys and then d, he will do the same
//Now lets do the Releasing keys first are the regular arrow keys, then the ducking
if jumping!=true{
if keyboard_check_released(ord('W')) && ducking!=true{
sprite_index=maneken_up; image_speed=0;
gms_instance_get(id, maneken_up); }
if keyboard_check_released(ord('S')) && ducking!=true{
sprite_index=maneken_down; image_speed=0;
gms_instance_get(id, maneken

Replies (3)

Last message on 27 Feb 2022

Size43 (Administrator) on 19 Feb 2022, 20:50:30
Your code cut off half way through, so I'm not sure if you said anything below it as well.

Your usage of gms_instance_get doesn't look quite right to me. gms_instance_get is returning a synced variable from an instance. It won't do anything when you call it on its own.

You might be looking for gms_optimize_variables.
GlitchLatch (Topicstarter) on 19 Feb 2022, 22:05:50
in general, I didn't quite figure out how to synchronize the walking animation, maybe I'll give you an gmk example?
Size43 (Administrator) on 27 Feb 2022, 15:27:20
You likely don't need any extra code. If you're just using sprite_index, that's synced automatically. What exactly does the game do right now, and what do you expect it to do?