# Timer-based Movement - { Tween }?

**URL:** <https://phaser.discourse.group/t/timer-based-movement-tween/3972>\
**Category:** Phaser 3\
**Created:** [October 16, 2019, 7:41pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972 "2019-10-16T19:41:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [October 16, 2019, 7:41pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972/1 "2019-10-16T19:41:32Z")

</div>

So I’m trying to get my game to run as efficiently as possible & I’ve run into quite the snag. How do I tween my Character’s move speed as well as animation speed & camera movement speed? I for some reason get some quirkiness that involves the camera ‘_lagging_’ for a second & I have a feeling it’s because I’m not using Timer based Movement.

---

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [October 17, 2019, 12:49pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972/2 "2019-10-17T12:49:54Z")

</div>

anyone can help?

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [October 17, 2019, 4:33pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972/3 "2019-10-17T16:33:32Z")

</div>

Can you show some code or an example? [https://codepen.io/pen?template=YeEWom](https://codepen.io/pen?template=YeEWom)

Probably you don’t need to tween the camera movement speed, just following the character would be enough.

---

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [October 17, 2019, 8:25pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972/4 "2019-10-17T20:25:38Z")

</div>

@samme of course! 🙂

Here’s some code I uploaded to Github :

> **[Thundros/simple-platformer](https://github.com/Thundros/simple-platformer)**
>
> A demostration of how to properly create a Platformer in Phaser 3 - Thundros/simple-platformer

Here’s the file that controls the player :

> <https://github.com/Thundros/simple-platformer/blob/master/src/js/player.js>

Specifically, Line{s} 129-224

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [October 18, 2019, 3:35pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972/5 "2019-10-18T15:35:27Z")

</div>

Increase the lerp values: [https://github.com/Thundros/simple-platformer/blob/50852dd85d2b21ff99ea4141e183f07785c6c358/src/js/platformer-scene.js#L125](https://github.com/Thundros/simple-platformer/blob/50852dd85d2b21ff99ea4141e183f07785c6c358/src/js/platformer-scene.js#L125)

You can also temporarily remove the camera deadzone or camera bounds to see if those are causing trouble.

---

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [October 18, 2019, 3:37pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972/6 "2019-10-18T15:37:38Z")

</div>

@samme Yea but I need a smooth camera. Not 1 that is snapped to the Player. Also, the character movement & animation speed, how do I tween the character movement & animation speed?

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [October 18, 2019, 8:31pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972/7 "2019-10-18T20:31:44Z")

</div>

I couldn’t get the example to run, but if the camera isn’t moving how you want, usually you would adjust the lerp, deadzone, and bounds.

Character movement is by velocity or acceleration. If you’re using acceleration then keep doing that.

I think you can adjust `sprite.anims.currentAnim.frameRate` while the animation is playing. Probably you would set that based on the player’s current velocity, not tween it.

---

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [October 18, 2019, 8:35pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972/8 "2019-10-18T20:35:50Z")

</div>

Try it again. I think I fixed the repo. I noticed I made a few typos. I just need my character to smoothly move as well as animate.

---

<div class="post-metadata">

**Author:** ![Thundros](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/thundros/32/2057_2.png) [@Thundros](https://phaser.discourse.group/u/Thundros)\
**Post date:** [October 20, 2019, 2:04pm UTC](https://phaser.discourse.group/t/timer-based-movement-tween/3972/10 "2019-10-20T14:04:06Z")

</div>

i adjusted the lerp deadzone & bounds. to no avail…
