1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 [SOLVED]New to GMS

Discussion in 'Programming' started by Quantum_Compooter, Aug 27, 2018.

  1. Quantum_Compooter

    Quantum_Compooter Member

    Joined:
    Aug 27, 2018
    Posts:
    6
    I am new to GMS as in I have less than 24 hours with it. I am simply trying to go from an idle animation to a run animation and back. I am using Spine Pro for the sprite animation. Anytime I move my sprite it just freezes. If I understand correctly it is because every "tick" it is restarting my run animation but I do not know how to rectify this. Any help would be greatly appreciated.

    Code:
    key_right = keyboard_check(ord("D"));
    key_left = keyboard_check(ord("A"));
    mv_dir = key_right - key_left;
    
    
    movement = mv_dir * walksp;
    
    x += movement;
    
    if(mv_dir != 0){
      image_xscale = mv_dir;
      skeleton_animation_set("Run");
    }else{
      skeleton_animation_set("Idle");
    }
    
     
  2. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    4,317
    Assuming this is a Step Event, you are setting the animation every single frame which results in it being set back to frame 0 every frame and this is why it appears to "freeze" - it's just frame 0 every frame.

    Add a check to see what animation is already playing before you set it, for example you only want to change to the "run" animation if the run animation isn't already playing.
     
  3. Quantum_Compooter

    Quantum_Compooter Member

    Joined:
    Aug 27, 2018
    Posts:
    6
    Ok I will give this a try. I appreciate it.
     
  4. Quantum_Compooter

    Quantum_Compooter Member

    Joined:
    Aug 27, 2018
    Posts:
    6
    This solved it. For anyone with this issue I used exactly this. I set a variable to skeleton_animation_get() and then if it wasnt set to the animation I wanted I set it.
     
    rIKmAN likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice