Can I make smooth animation ?

Just started using Construct 2? Post your questions here

Post » Fri Apr 14, 2017 6:59 am

Hi.

At this moment, I'm moving my character using the simple way

player.X = player.X + 64 ( :v ) so, the player jumps instandly to the next position

I want to know if it is possible to make that movement smooth, like a transition (?)

I read about lerp, but I don't know if I can use it in this case or if there is a different way to make it.




Thanks you all.
B
8
Posts: 5
Reputation: 310

Post » Fri Apr 14, 2017 7:21 am

Yes you can use lerp also.
lerp works kind of like this.

lerp(sprite.startposition, sprite.endposition, 0.1)

0.1 is 10% of the distance per tick.

You can also try a plugin called liteTween you can find it here on the forums. It can do similar a thing but with much more nice acceleration and smooth movement. Highly recommended, as lerp is only linear.
Follow my progress on Twitter
or in this thread Archer Devlog
B
41
S
18
G
19
Posts: 1,047
Reputation: 13,986

Post » Fri Apr 14, 2017 8:00 am

tunepunk wrote:Yes you can use lerp also.
lerp works kind of like this.

lerp(sprite.startposition, sprite.endposition, 0.1)

0.1 is 10% of the distance per tick.

You can also try a plugin called liteTween you can find it here on the forums. It can do similar a thing but with much more nice acceleration and smooth movement. Highly recommended, as lerp is only linear.



Thanks for responding tunepunk

The problem is:

It is a loop who moves the character, like this
Image

so, if it is 1 - move the player right, if it's 2 - move the player left and the same for up and down
that's why I need to use a "wait" there, in the loop.

I used lerp, following what you said but the character barely moves.

I don't know what to do, even if it is possible into a loop
B
8
Posts: 5
Reputation: 310

Post » Fri Apr 14, 2017 8:03 am

Why would you do this in a loop ?
Are you aware that the events already run in a 'big' loop ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Apr 14, 2017 8:27 am

99Instances2Go wrote:Why would you do this in a loop ?
Are you aware that the events already run in a 'big' loop ?


I know, I know
But I need the real player selects his movements first i.e
The player wants to go right, right, down and right, so he will select those movements from a list and when he finishes, presses play and the character Will move according those selected movements​

I had to do that because someone else needs it that way
B
8
Posts: 5
Reputation: 310

Post » Fri Apr 14, 2017 8:44 am

I'm not really sure what you are trying to do with the looping, but maybe it's better if you just set a variable in the loop, and do the ectuap movement outside the loop when that variable is set.
Follow my progress on Twitter
or in this thread Archer Devlog
B
41
S
18
G
19
Posts: 1,047
Reputation: 13,986

Post » Fri Apr 14, 2017 11:51 am

Ah ok. One of the many ways.

https://www.dropbox.com/s/yx2fmprpiqdqy ... .capx?dl=0

Using the MoveTo plugin, behavior-moveto_t63156
I was a bit done with all the lerping 2day.

As you see. You can not lock the interactivity of the player up in a loop. And you can not lock this moving (that takes time) up in a loop. A loop happens in the same tick. This movement happens over several ticks.
Normally i wouldo this with instances of the same sprite for the player, but i feel that you learn more of it (for now) if i use two different sprites.

Have fun coding.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Apr 14, 2017 11:36 pm

Message: jdvergarad can only post plain text URLS until they have 500 rep. 2 URLS modified. Why?
99Instances2Go wrote:Ah ok. One of the many ways.

https://www.dropbox.com/s/yx2fmprpiqdqy ... .capx?dl=0

Using the MoveTo plugin, behavior-moveto_t63156
I was a bit done with all the lerping 2day.

As you see. You can not lock the interactivity of the player up in a loop. And you can not lock this moving (that takes time) up in a loop. A loop happens in the same tick. This movement happens over several ticks.
Normally i wouldo this with instances of the same sprite for the player, but i feel that you learn more of it (for now) if i use two different sprites.

Have fun coding.




thank you

I am going to try
I'm new with this so, I'm doing my best :roll:
B
8
Posts: 5
Reputation: 310


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest