Search Unity

Using Brackeys Character Controller my player is animated but wont move?

Discussion in '2D' started by bridgetkacprzyk174, Jul 14, 2019 at 2:24 PM.

  1. bridgetkacprzyk174

    bridgetkacprzyk174

    Joined:
    Jul 5, 2019
    Posts:
    3
    I'm new to Unity so I'm sure I'm missing something small.

    I've been following Brackeys tutorials on YouTube. Right now I'm on animation (
    ). I've watched and rewatched the video to try and figure it out myself but I'm still stuck. My player does the animations when the keys are pressed, however he doesn't go anywhere. This wasn't a problem before I added animations. I'm at a loss for what to do next. So if anyone has personally used this tutorial can help me that would be great. This is my PlayerMovemenr script.

    Code (CSharp):
    1. public class playermovement : MonoBehaviour
    2. {
    3.     public CharacterController2D controller;
    4.     public Animator animator;
    5.  
    6.     public float runSpeed = 40f;
    7.  
    8.     float horizontalMove = 0f;
    9.     bool jump = false;
    10.  
    11.     void Update()
    12.     {
    13.         horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
    14.  
    15.         animator.SetFloat("Speed", Mathf.Abs(horizontalMove));
    16.  
    17.         if (Input.GetButtonDown("Jump"))
    18.         {
    19.             jump = true;
    20.         }
    21.     }
    22.  
    23.     private void FixedUpdate()
    24.     {
    25.         controller.Move(horizontalMove * Time.fixedDeltaTime, false, jump);
    26.         jump = false;
    27.     }
    28. }
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    4,796
    Do you use same version of Unity as tutorial was made with?
     
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    1,322
    Also, are you getting any errors in the console?