V
V
viliamon2020-08-16 09:25:43
Unity
viliamon, 2020-08-16 09:25:43

Why is my unity2d character not moving?

The character does not respond to movements, although the code was written, and also gives the following error:
5f38d0f11ccfc698883246.png
Here is the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
    Rigidbody2D rb;
    public float speed;

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    void FixedUpdate()
    {
        rb.velocity = new Vector2(Input.GetAxis("Horrizontal") * speed, rb.velocity.y);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2020-08-16
@viliamon

No need to produce questions. Although this one is formatted according to the rules, so...
You don't have the axes set up. To set up the axes - in the Edit->Settings->Input unit (it's in the menu).
But in general - it seems that there is a horizontal axis by default - it only remains to write it correctly - you have a typo in the word Horrizontal - it should contain one r.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question