Search Unity

Unity Top Down 2d Game Input Not Workin

Discussion in '2D' started by andreasmangib, Apr 11, 2019.

  1. andreasmangib

    andreasmangib

    Joined:
    Jan 25, 2019
    Posts:
    6
    Hi!

    I'm making a top-down 2d game. I have the code right. but the console keeps saying this(1. picture) Error2.PNG
    Here's the code

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class PlayerMovement : MonoBehaviour {
    6.  
    7.     public float speed;
    8.     private Rigidbody2D myRigidbody;
    9.     private Vector3 change;
    10.  
    11.     // Start is called before the first frame update
    12.     void Start () {
    13.         myRigidbody = GetComponent<Rigidbody2D>();
    14.     }
    15.  
    16.     // Update is called once per frame
    17.     void Update() {
    18.         change = Vector3.zero;
    19.         change.x = Input.GetAxisRaw("Horizantal");
    20.         change.y = Input.GetAxisRaw("Vertical");
    21.         if(change != Vector3.zero)
    22.         {
    23.             MoveCharacter();
    24.         }
    25.     }
    26.  
    27.     void MoveCharacter()
    28.     {
    29.         myRigidbody.MovePosition(
    30.             transform.position + change * speed * Time.deltaTime
    31.         );
    32.     }
    33. }
    34.  
     
  2. andreasmangib

    andreasmangib

    Joined:
    Jan 25, 2019
    Posts:
    6
    Oh and here's the input folder
    input folder.PNG
     
  3. Aryel-Sander

    Aryel-Sander

    Joined:
    Dec 24, 2014
    Posts:
    1
    change.x = Input.GetAxisRaw("Horizontal");
    You wrote "Horizantal" not "Horizontal".