1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GML How to Ease in and Out?

Discussion in 'Programming' started by ethian, Aug 24, 2018.

  1. ethian

    ethian Member

    Joined:
    Apr 19, 2018
    Posts:
    297
    Greetings...
    [​IMG]
    I always wanted to know how to do this and not this:
    [​IMG]
    (Inside paths)
    [​IMG]
    (Angles)
    I know is called ease in and out, but...
    How to make the objects move on that way when are running on paths via code? Is it possible? What about the other way? And with angles?
     
  2. Nexusrex

    Nexusrex Nexusrex Games

    Joined:
    Jun 20, 2016
    Posts:
    211
    Some command like 'lerp' shall be helpful in cases like those.
     
  3. ethian

    ethian Member

    Joined:
    Apr 19, 2018
    Posts:
    297
    I know "Lerp" does this but... how to use it to make objects move like the animations i shown?
     
  4. GloveGames

    GloveGames Guest

    my_position = Lerp(my_position, target_position, speed);

    if speed is 1, then it will be instant. (return target_position)
    if speed is 0, then we won't move (returns my_position)
    if speed is 0.1, then it will take (roughly) 10 frames to move there

    the reason you get a smooth movement is because you are moving a fraction of the distance each frame, but because that distance is getting less each frame it appears to slow down as we reach our destination.

    note: may never reach the exact mathematical position since we are moving a fraction of the distance each frame (unless speed is 1)

    for that wobbly **** that Cactus does, you're gonna want to look into something called a sine wave
     
  5. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,077
    Bentley likes this.
  6. Ludorverr

    Ludorverr Member

    Joined:
    Jun 20, 2016
    Posts:
    33
    You should use free scripts from the marketplace to do this, because every easing pattern has a complex mathematical formula behind it, if you attempt to write it yourself then you truly are reinventing the wheel. Honestly something like this feels so basic and essential that I believe it may as well be built-into Game Maker itself.

    The one I always used was:
    https://marketplace.yoyogames.com/assets/2395/easing-and-tweening
    It includes only the easing scripts without any other junk added. I guess the reason I was drawn to that one was because it had this very important pic:
    6644_original.png
    Which gives you a quick idea of how each easing script operates. There's a better quality picture on https://easings.net/
     
    Last edited: Aug 24, 2018
  7. ethian

    ethian Member

    Joined:
    Apr 19, 2018
    Posts:
    297
    I checked a downloadable .gmx that contains coded easing animations. I checked their codes and, yes! It includes something mathematical...
    Isn't "sin", "cos" and "tan"? I now know what they mean! Thanks to the school!
    Also...

    I found this video, it contains a script that makes object ease in and/or out when using them... similar to what gave me to me... yay!
    But is for GMS2 only... some other similar script for GMS1?
    [​IMG]
    I just wanted to use linear easing effects to make a coded animation like this using paths and others for non-easing parts... and the script for the easing parts, for example...

    And for make a sprite ease in and out on a vertical line like the pirate ship from this video.
     

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