S
S
Stason4ikRU |2019-07-27 22:01:30
2D
Stason4ikRU |, 2019-07-27 22:01:30

Character movement script not working. What to do?

I want to make a 2d game with a top view. I wrote a script, but for some reason it does not work. Unity does not write an error, the script just does not work and that's it. Unity version 2018.2.2.1 and 2019.1.12f1 (tried on both)

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

public class PlayerMove : MonoBehaviour
{
    [SerializeField]
    public float speed;
    private Rigidbody2D rb;
    [SerializeField]
    private Vector2 moveInput;


    private void Awake()
    {
        rb = GetComponent<Rigidbody2D>();
        
    }

    private void Update()
    {
        moveInput = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        moveInput = moveInput.normalized * speed;
    }

    private void FixiedUpdate()
    {
        rb.velocity = moveInput;
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Filonenko, 2019-07-28
@Stason4ikRU

You have already been advised to start using the debugger. But you probably have a banal typo in the name of the FixedUpdate() method. You have written FixiedUpdate().

G
Griboks, 2019-07-28
@Griboks

Maybe moveInput is null.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question