simple 2d movement script doesn't work

This is a very simple 2d right & left movement script. I don’t know why it doesn’t work. Is there something I don’t see or the problem isn’t from script?

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

public class PlayerController2D2 : MonoBehaviour
{

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

    // Update is called once per frame
    private void Fixedupdate()
    {
        if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
        {
            rb2d.velocity = new Vector2(2, 0);
        }
        else if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
        {
            rb2d.velocity = new Vector2(-2, 0);
        }
    }
}

It would be helpful to describe what you mean by “doesn’t work”.

Anyway, C# is case-sensitive so “Fixedupdate” isn’t called by Unity, it looks for “FixedUpdate” and calls that.

2 Likes

See @MelvMay 's post for the answer to your problem.

I don’t understand how you guys keep writing these methods names wrong since the IDE you use, most likely Visual Studio, VSCode or Rider, writes them for you. Only Monodevelop doesn’t do that.