0
\$\begingroup\$

In a game I have a specific object and two positions the object will move from and to. I already have the function for calculating current position in specific time.

It works like this:

Inputting 0 will move the object to Position 1.

Inputting 1 will move the object to Position 2.

Inputting 0.5 will move the object in the middle of the two positions.

etc...

(In the examples below, time is varying from 0 to 1) When I want to start the object slowly and stop it when it is moving fast, I use:

MoveObject(sin(time * 90))

When I want to start the object fast and stop it as it is getting slower, I use:

MoveObject(1 - cos(time * 90))

Without the effects, it's:

MoveObject(time)

How do I make the object start moving slowly, move fast in the center of two positions and then get slower while reaching the second position?

\$\endgroup\$
4
  • \$\begingroup\$ what about MoveObject(sin(time * 180))? \$\endgroup\$
    – Ali1S232
    Commented Mar 30, 2013 at 19:08
  • \$\begingroup\$ This type of method would vary from 0 to 1 then again to 0 \$\endgroup\$ Commented Mar 30, 2013 at 19:10
  • \$\begingroup\$ Here's an interesting read about easing equations: sol.gfxile.net/interpolation \$\endgroup\$
    – Alayric
    Commented Mar 30, 2013 at 19:18
  • \$\begingroup\$ so there is tanh function, but it needs some preparations before using... maybe MoveObject((tanh(time * 180 - 90) + 1) / 2) \$\endgroup\$
    – Ali1S232
    Commented Mar 30, 2013 at 20:13

1 Answer 1

2
\$\begingroup\$

You are looking for easing functions...

Here you have some desription: http://www.gizma.com/easing/#expo1

I wrote a reply about them here with my own implemntation in C#

https://gamedev.stackexchange.com/a/26872/8390

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .