2D Player Movement Bug - speeding up on mutiple clicks


#1

My player movement works fine if I wait until he reached the destination to then, send it to another 0:00 - 0:07 on the video:

But when I do multiple clicks, he “speed up” and make a strange effect on screen (0:08 - 0:015 on the video)

I’m calling the function UpdateTargetPosition(); of TargetMover script on Input.GetMouseButtonDown(0). Even with double click pattern this happens.

I tried to debug many things on AiLerp script but didn’t find the solution.

Please help


#2

Hi

What are your Seeker -> Start End Modifier settings?


#3

Both Node Center:


#4

Okay. I would recommend that you set Start Point Snapping to Node Connection (also explained here: https://arongranberg.com/astar/docs/ailerp.html). What happens right now is that if the AILerp script tries to calculate a new path when it is in between two nodes, the start point will be snapped to either the node center it came from or the one it is moving too, either way it introduces a discontinuity when following the path. It will smooth out that discontinuity (controlled by ‘Interpolate Path Switches’) however it will look like it is either speeding up or slowing down for a short duration.


#5

Thank you Aron!

Now I figure out, End Point with Node Center and Start Point with Node Connection works perfectly!

You are mading an excellent job with this asset, I’m so grateful to you!

I’m sorry for the title of post saying “bug”, there is no one.

Thank you!


#6

Thank you for the kind words! :slight_smile:
If you feel like supporting the asset even more, a rating or a review in the Unity Asset Store goes a long way :slight_smile:


#7

I definitely will!

Just one more thing

With this setup, I’m facing a strange behavior at the start of the path some times when I change the direction.

You see that at the beginning the player done an “unecessary” movement.

Can I do something to avoid that?


#8

Hi

You could use the ‘Closest On Node’ setting for ‘Start Point Snapping’ instead. I think that will do what you want. With the ‘Node Connection’ mode it will always move along node connections, so that detour is necessary.

If you want smoother movement you could use for example a raycast modifier. See this page https://arongranberg.com/astar/docs/ailerp.html and this page for more info: https://arongranberg.com/astar/docs/modifiers2.html
(or just use the AIPath movement script which generally follows the path in a smoother way)


#9

Yeah, ‘Closest On Node’ did the trick.

I’m sorry I thought I tested it,

Thank you again!