Movement in Unity Errorerro

Started by
1 comment, last by ShallowDeveloping 2 years, 9 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!

Advertisement

bump

This topic is closed to new replies.

Advertisement