Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Jittering with following path

Discussion in 'Scripting' started by AustinRichards, Dec 17, 2014.

  1. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    I developed my own pathfinding system and walking system that follows the designated path.
    One issue i've been having is making it smooth in certain situations. In most situations, it's great, but because it's a grid based path system I get it zig zagging back and forth due to the nature of how the nodes are placed.

    Here's a little mp4 Gyazo clip of it: http://i.gyazo.com/cc84a7470bb96d7670cdb390ff9d0ec9.mp4

    Does anyone have any tips on how to handle this? I've looked into bezier curves but haven't been sure if it's what I need. I still need it to be accurate to the path.
     
  2. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Fixed by making the character move to the average position of 3 points (the previous path point, the current target point, and the future point) so if there's a zig zag path, it'll average it out. The zig zagging is about 95% gone at that point, so then I made it so the character rotates slower when he's rotating lower amounts. So if he rotates 180 degrees it's at full speed, but if he's rotating at about 10 degrees its pretty slow, that way it hides the little bit of zig zag that was left.

    :)