Advertisement

Movement in Unity Errorerro

Started by August 14, 2021 05:38 PM
1 comment, last by ShallowDeveloping 3 years, 6 months ago

Hello! I have recently started to make a 2D platformer in Unity, and although I have followed several tutorials with different methods, I have came up with the same result continuously - not working. I am using Microsoft's Visual Studio Code. Here is my script - 
using System.Collections;

using System.Collections.Generic;

using UnityEngine;


 

public class PlayerMovement : MonoBehaviour {

    public float movementSpeed;

    public Rigidbody2D rb;


 

    float mx;


 

    private void Update() {

        mx = Input.GetAxisRaw("Horizontal");

    }


 

    private void FixedUpdate() {

        Vector2 movement = new Vector2(mx * movementSpeed, rb.velocity.y);

        rb.velocity = movement;

 

 Apparently the code it working for other people, and it should be producing this - 

But I am receiving this - 

I am sure it is something stupid that I am not doing right, but please help. Thanks in advance!

bump

This topic is closed to new replies.

Advertisement