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

help with 2D charactor

Discussion in 'Scripting' started by unity_kxPFhIjmTIXcow, May 1, 2020.

  1. unity_kxPFhIjmTIXcow

    unity_kxPFhIjmTIXcow

    Joined:
    Feb 21, 2020
    Posts:
    4
    Hi, this is my first time coding. I need my character to move the x-axis and y-axis. But the code doesn't seem to work (my character doesn't even move)... I have no idea why. I would appreciate it if someone would help me.

     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,735
    MoveSpeed is zero. Zero times any vector is the zero vector. I suggest making MoveSpeed public (or give it a [SerializeField] attribute), and assigning a value to it in the inspector.
     
  3. unity_kxPFhIjmTIXcow

    unity_kxPFhIjmTIXcow

    Joined:
    Feb 21, 2020
    Posts:
    4
    Thanks. Now I can control the speed, but I still can't move him. :)
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
    The script you posted is PlayerController. I do not see a PlayerController script on your player. I see a PlayerPlatformer... the filename must precisely match the classname, down to the capitalization and spelling.
     
  5. unity_kxPFhIjmTIXcow

    unity_kxPFhIjmTIXcow

    Joined:
    Feb 21, 2020
    Posts:
    4
    I noticed a few seconds later after posting