I have problem with my 'jerky' movement by using "lerp"...

0 favourites
  • 5 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi.

    I'm making logic-platform game and i want to make smooth, jerky movement - like jumping frog in my game, but i have problem with precision to keep 'PlayerObject' jumping in specified distances - like at 100 pixels for example.

    I used "lerp" to make it smooth, but I'm not sure if it is good idea.. maybe i should make it in other way?

    My goal is to make simply movement like: smooth move about 100 pixels on the right (or left) with little jump.

    Problem is, that the lerp has digits after the decimal point - so when I'm hitting the "right arrow" key to make this movement - the player has jumping fast, but not precise and it lands (stop lerp animation) farther than it should (or closer). You can see that by tiled floor (builded on the grid)..

    I made instance variable to my Player object with name: canMove to control jumps and precision. So from default "canMove" is on true, but when the lerp animation is "playing" it should be on "false" (i set this by making action after pushing "Right arrow" to make move).

    So i tried to find the end point of lerp animation - i thought it is Player.X >= Player.TargetX and than set the "canMove" to "true". But i don't know what i'm doing wrong..

    Im attaching my capx of this movement. So i hope someone can help me.

    dl.dropboxusercontent.com/u/830 ... ecise.capx

    And I hope that I've written quite understandable <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz" />

  • Hello.

    Unfortunately, I cannot see your link for the capx, so I'm not sure that I can help. I think you might be running your event multiple times while your key is pressed. Are you familiar with "trigger once while true?" Adding this to your key press condition may solve your problem. https://www.scirra.com/manual/124/system-conditions

  • In my opinion, it is easyer to use the LiteTween plugin.

    behavior-litetween_t70700

    But, that is not your qeustion. So, let me try to give a good answer.

    First of, i am aware that mostly lerp gets used with a dynamic start point, a static endpoint and a static lerpfactor. A lerpfactor that has to be dt corrected. And that is not really easy.

    This way the next step gets smaller and smaller (but never zero), giving some (in my eyes fake) feeling of smoothing out. But, you will have to when the target is moving. That is (if i understand right) not you case.

    So, under the condition that the target is not moving, lerp can be used in much (again in my eyes) better way.

    Basically using a static start, a static end and a dynamic lerp factor (that is already dt corrected in the right way)

    Besides that. there is not only lerp, but also qarp and (very usefull) there is cubic.

    In this example i use cubic to easy-in and easy-out a movement. I kept it as 'visual' and as 'simple' as possible.

    Look at the imagepoints on the ruler.

    https://drive.google.com/open?id=0B1SSu ... nZReFFzWEU

    Hope this opens your eyes to new ways. Greetings.

  • jasmattkrz yes.. unfortunately i can't paste links because of my low number of reputation points..

    Maybe on this way : dl dropboxusercontent com/u/8305038/Jerky%20Movement/JerkyMovementNotPrecise capx (put dots instead of spaces)

    I think that i tried with that trigger "once" but I'm not sure, i must check it.

    99instancesToGo i cant open your capx, because you're using newer version of C2.. unfortunately newer version doesn't work in my computer.. so i must to use r209 version..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I want to make a suggestion to help but really don't understand the

    ...i want to make smooth, jerky movement - like jumping frog in my game

    You could use lerp() but I wouldn't use a static third variable—that smoothing wouldn't make me think of a frog jumping. I usually use lerp with instance variables so it looks like lerp(starting, finishing, progress) and put it in a deactivated group. Set progress to 0, activate the group where every tick add speed (another variable) to progress and when progress >= 1 deactivate the group.

    Of course you can do this a bunch of different ways. If it is a jumping look you are going for I made these blobs with custom movement and timers, and of course animations:

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)