Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

2D character not moving

Discussion in 'Scripting' started by footballhono52, Dec 13, 2015.

  1. footballhono52

    footballhono52

    Joined:
    Dec 3, 2015
    Posts:
    16
    I'm practicing making an infinite runner game using my own 2D Sprite and Bone Skeleton animations in unity. I have the animation of running all complete but I'm having trouble getting the animation to run with the character controller. When I run the game the animation plays of the character running but it stays in the same place, I can't control it at all.

    I've viewed all the tutorials online and I just can't get seem to get it to work. The code I have is as follows, very simple :

    Code (CSharp):
    1. Public Rigidbody2D burgled;
    2. Public float speed;
    3.  
    4. Void start()
    5. {
    6.    burgler = GetComponent<Rigidbody2D>();
    7. }
    8.  
    9. Void Update()
    10. {
    11.    float move = Input.GetAxis("Horizontal");
    12.  
    13.    burgler.velocity = (move * speed, burgler.velocity.y);
    14. }
     
  2. footballhono52

    footballhono52

    Joined:
    Dec 3, 2015
    Posts:
    16
    It is Public Rigidbody2D burgler;

    It won't let me edit it