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

Question Move with constant speed

Discussion in 'Visual Scripting' started by Dev01s, Jan 24, 2021.

  1. Dev01s

    Dev01s

    Joined:
    Jan 24, 2021
    Posts:
    1
    Hello everybody! I have a character that I want to move in the XZ plane. I have already learned how to get coordinates when touch on this plane, but now the character moves there instantly, or when adding the Lerp method with constant touch. How to correctly implement the character's path from point A to point B at a constant speed as in RTS?
    1.jpg 2.jpg
     
  2. toomasio

    toomasio

    Joined:
    Nov 19, 2013
    Posts:
    198
    You need to get the distance between the two points.
    then you get the distance divided by speed, which will be the time in seconds.
    then you lerp from Pos A to Pos B using that time.
     
    Dudusstar likes this.