Search Unity

Using Lerp with an animated character

Discussion in 'Navigation' started by Bearhugger, Mar 25, 2021.

  1. Bearhugger

    Bearhugger

    Joined:
    Feb 26, 2020
    Posts:
    2
    Hi,
    I want to make a character (agent) move to another agent automatically.
    I only got it to work with

    Code (CSharp):
    1. private void FixedUpdate()
    2.     {
    3.         GameObject UnitPlayer = GameObject.FindGameObjectWithTag("Player");
    4.  
    5.         transform.position = Vector3.Lerp(transform.position, UnitPlayer.transform.position, Time.deltaTime);
    6.      
    7.     }
    But: The closer the agent gets to the other agent it gets slowed down.
    Also, and that is my main gripe, that humanlike character doesn't walk anymore.
    It just "flies". So, I don't know how to play the animation alongside the Lerp.

    Thx.

    Regards

    Jan
     
  2. Bearhugger

    Bearhugger

    Joined:
    Feb 26, 2020
    Posts:
    2
    ok, can be closed.
    Found a different solution around this problem.