Fixed Walking Distance, Posible?

Hey everyone! :o

I am constantly learning stuff and are very happy with all the resources I can find on the forums, however there is one thing that I would really like to know but I haven’t been able to find it. (searched for: fixed steps, fixed walking, fixed distance etc.)

I am trying to let my character walk a fixed walking distance.
To explain myself, let’s take the Lerpz Platformer Demo. If you press the [->] button it walks.
If you press it shortly let’s say 1 second, it may move from point 0.0 to 0.5
if you press it a little bit longer, 1.5 seconds, it may move from point 0.0 to 0.75

Now what I want to do is, When I press the [->] button once, I would like my character to walk from point 0.0 to 1.0
When I hold the [->] button I would like it to walk steps of 1.0, so first 0.0 to 1.0, then 1.0 to 2.0, 2.0 to 3.0 etc.

I hope I explained myself correctly :o As I searched the entire forum but could not find anything I’m kind of desperate :frowning: :stuck_out_tongue:

Cheers,
Tim

There’s no one way but there are ways, depending on what you want.

I’ll give you some high up descriptions from different methods I can think of:

If you want him to get there at a constant speed, simple record the stop position when he starts to move and each update, check if he’s there; if not, move him closer by some speed.

If you want him to move in same-time increments then, when you start the move, record the distance he needs to travel and divide that by the length of time you want him to take to get there and move him by that (modified by timeDelta as usual) each update for the total time.

Hope that gives you some ideas!

Thank you :wink:

I’m still kinda lost here, I am using the 2D Platformer Example and I’ve found some scripts I think needs editing for my needs in PlatformerController.js.

So what I understand from your explanation is that I need a script that says, When on 0,1 to 0,9 move. When 1.0 is reached, stop.
Is this correct?

Thank You :slight_smile:

  • Tim

Bump, Anyone willing to help please? :sweat_smile:

ps: is it allowed to bump your topics on these forums? Some allow it others don’t, sorry if it isn’t allowed.

I’ve attached an example project that should help explain what you need to do here. Walking in steps is generally about determining the start and end positions of the step and then sliding the object in between those positions over a period of time. Also, the script will usually need to have two “modes” to handle the moving state and the idle state. Once a keystroke is detected, the object enters its moving mode and continues until the movement has finished. It then returns to idle mode where it can detect new keystrokes.

194814–6941–$stepmovement_206.zip (1.09 MB)

That is awesome Sir!
Thank you SO MUCH :o

Thanks andeeee! This is great!