Search Unity

Stopping Teleport Back

Discussion in 'Scripting' started by therealbobx3, Jun 12, 2018.

  1. therealbobx3

    therealbobx3

    Joined:
    Apr 22, 2017
    Posts:
    5
    Hey Guys,
    i'm pretty new to Unity and i'm using the Animation from mixamo and if i'm pressing w i want that the character is moving. The character is moving but when i stop pressing 'w' the character is teleporting back to the position. Can anybody tell me how to fix it?
    Thx.
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  3. therealbobx3

    therealbobx3

    Joined:
    Apr 22, 2017
    Posts:
    5
    Code:
    Code (CSharp):
    1. public override void OnStateUpdate(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex)
    2.     {
    3.         Debug.Log("TEST1");
    4.         if (Input.GetKey(KeyCode.W)) {
    5.  
    6.         Debug.Log("TEST");
    7.         animator.Play("Walking");
    8.     }
    9.     }
    Gif what happens:
    https://gyazo.com/0ba63ac632e116c180c4c1aed47ee521

    Using:
    Basic Locomotion Pack from mixamo
     
  4. therealbobx3

    therealbobx3

    Joined:
    Apr 22, 2017
    Posts:
    5
  5. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    The only thing that is moving is the animation(I guess), check the root motion variable on the animator if you want to move by animation

    Also, you're doing it way wrong, look at some tutorials
     
  6. therealbobx3

    therealbobx3

    Joined:
    Apr 22, 2017
    Posts:
    5
    "You're doing it way wrong" what am i doing wrong lol
     
  7. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Its hard to say because I don't know exactly what you're trying to do, but if you look at tutorials on this you'll see what I mean.
     
  8. therealbobx3

    therealbobx3

    Joined:
    Apr 22, 2017
    Posts:
    5
    Well fixed it just have a little problem now. Idk if you can see it but the leg is a little bit buggy idk i think i need to do something with the transitions but dont know what i appreciate every help. Thx
    Gif:
    https://gyazo.com/87840e077d130da7fef1af5003866ad9
     
  9. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536