GML How to Ease in and Out?

E

ethian

Guest
Greetings...

I always wanted to know how to do this and not this:

(Inside paths)

(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?
 
N

Nexusrex

Guest
Some command like 'lerp' shall be helpful in cases like those.
 
G

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
 
L

Ludorverr

Guest
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 by a moderator:
E

ethian

Guest
You should use free scripts from the marketplace to do this, because every easing pattern has a complex mathematical formula behind it
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?

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.
 
Top